The prefix symbol
Mark Thornton
mthornton at optrak.com
Mon Jun 20 13:37:17 PDT 2011
On 20/06/11 21:19, Pavel Minaev wrote:
> I would prefer to see "^" instead:
>
> ^x -> x + 1
>
> ^(x) { return x + 1; }
>
> ^{ x -> x + 1 }
>
> The main reason is actually purely subjective preference for the look: I
> feel that it is less visually noisy than "#", where the latter gives undue
> weight to the start marker of the lambda, and not to the important parts of
> it (i.e. argument list and body). At the same time, "^" sits rather above
> the baseline of the text, making it easy to distinguish when you are
> actually scanning for the beginning of the lambda.
>
> The secondary reason is that "^" remotely resembles the lambda character, so
> it is somewhat mnemonic.
>
> To the best of my knowledge, there are no parse problems here - while "^" is
> an existing binary operator, there are no contexts in which it could be
> confused for the above syntax.
>
> A potential disadvantage is that "^" already means xor, and is being reused
> here for a completely unrelated thing. But I think that xor is very
> infrequent in typical Java code, and so there is little potential for
> confusion here.
I don't think it is all that rare, but then I'm also one of those people
who have used 'lambda' as a variable name.
Mark Thornton
More information about the lambda-dev
mailing list