Lightweight lambda syntax
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
One of jsonnet's big selling points is being able to write functions and pass them around as values. Can we have a more lightweight syntax for anonymous functions than the `function (args) ...` one? I catch myself deliberately trying to to avoid writing them due to the syntactic noise.
I don't really have a proposal for the syntax I want, but here are a few lightweight ones (not sure how compatible they are with your current grammar):
- Scala: `(arg1, arg2) => body` (probably requires nontrivial lookahead and complicates the parser, but is pretty appealing from a human standpoint)
- Haskell: `\arg1 arg2 -> body` (all functions are unary, but this is a shorthand for two lambdas)
- Nix: `arg: body` (all functions are unary)
Contributor guide
Assessment
This issue has not been assessed yet.