Inverted syntax option

John Nilsson john at milsson.nu
Mon Mar 15 14:56:16 PDT 2010


On Mon, Mar 15, 2010 at 8:09 PM, Bob Foster <bobfoster at gmail.com> wrote:

> Perhaps you meant this to illustrate how awkward and regressive this
> numbered-argument syntax is, and if so I applaud you for the examples.
>
> If this is a serious proposal, I suggest swapping the % character for #
> (the parser can figure it out by its prefix operator position) so everyone
> will understand that the new model for the Java language is the MS-DOS
> command line.
>
>    baz(%1 + %2)
>

;-) I was actually thinking of $1 + $2 (Bash style) but $ is already a valid
identifier as far as I know...

But yes it was intended as a serious proposal. If the alternative is some
monstrosity such as new lambda<int,int>(int a, int b) { return a + b: } to
express a simple concept that shouldn't require more characters than one to
be perfectly clear: +

I'm quite found of the Scala approach to lambdas where syntax is mostly
optional when the context can be used to infer the intended lambda. #1 + #2
is kind of compromise in that regard as it has been my impression that the
Java crowd here isn't to found of terseness.

BR,
John


More information about the lambda-dev mailing list