google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.87k stars 437 forks source link

Shorthand for curried functions #223

Open copumpkin opened 8 years ago

copumpkin commented 8 years ago

I love partial application, especially in the presence of HOFs, but especially with the long syntax for lambdas it's currently pretty heavyweight to write those. Even if the syntax were more lightweight, I believe the following could be quite nice:

local foo(params1)(params2) = ...;

as shorthand for:

local foo(params1) = function (params2) ...;

Given that we already have the local foo(params) = ... as sugar for local foo = function(params) ..., it seems like iterating the current rule for each group of parentheses would be a nice generalization of the syntax. Same would apply to object "keys", as well as anonymous functions.

sparkprime commented 8 years ago

This looks quite unintrusive and it's nice that the definition syntax still resembles the calling syntax.