google / google/jsonnet

Nicer syntax for higher level functions

Open
#1,002 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

I love the pure functional nature of Jsonnet! However, when trying to do things in a functional style, the syntax gets in the way a _bit_ (not a lot, but a _bit_).

For example, defining higher level functions is a bit clumsy:

```jsonnet
local f = function(x) function(y) function(z) z*y*z;
```

I think such functions would be more natural to use, and therefore get used more often, with more succinct syntax – and there's no need to invent anything fancy, since lots of other languages already use either a "fat" or a "thin" _arrow_, `=>` or `->`.

So the above snippet would become:

```jsonnet
local f = x -> y -> z -> z*y*z;
```

This would also be nice and eligible for inline uses, e.g. `std.filter(thing -> thing.isActive, things)`.

Hoping y'all think it makes sense! 🤞

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.