Nicer syntax for higher level functions
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Domain
- compilers
Research direction
The issue proposes arrow syntax for defining and using higher-order functions, with examples for nested functions and std.filter. Start by reviewing Jsonnet's language grammar and parser entry points, then find the syntax tests covering function expressions. Done means the proposed arrow forms are accepted consistently and existing function syntax remains covered.
Written by the indexing model from the issue text.
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:
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:
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! 🤞
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 477
- PR merge metrics
- No merged PRs in 30d
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/jsonnet
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
-
std.format: wrong digits for %f/%d on large values; malformed output for non-integer * precisionOpen
Difficulty 4/5 3-5 days Newbie friendliness 52/100
-
Difficulty 5/5 Over a week Newbie friendliness 42/100
Similar issues
-
self-host checker: E021 bound check reads an untyped literal at i32, not the type the call bindsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
JakeChampion/lang#11055 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day