The prefix symbol
Pavel Minaev
int19h at gmail.com
Mon Jun 20 13:19:13 PDT 2011
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.
On Mon, Jun 20, 2011 at 10:54 AM, Stephen Colebourne
<scolebourne at joda.org>wrote:
> The four syntax families split into two types, those with a prefix
> symbol and those without.
>
> The prefix symbol is commonly mentioned as #:
>
> #(x) { return x + 1; }
> #{x -> x + 1}
>
>
> *** If you have a strong desire to see any symbol other than #
> considered then please respond to this thread. ***
>
> - Your reply MUST specify the symbol
> - Your reply MUST give a brief justification
> - Your reply MUST repeat the two examples above using your preferred symbol
> - You SHOULD try to ensure that your alternate symbol choice would
> parse acceptably
> - You MAY reply to suggest a keyword, however you should expect that
> to be rejected
>
> Thread rules:
> - Only reply if you prefer your alternate symbol to #
> - To discuss something, change the thread title
> - Don't reply just to say "I don't want a prefix symbol"
> - Responding with a symbol suggestion doesn't preclude your first
> choice actually being "no prefix symbol"
>
> For example, my preferred choice of prefix symbol is #, thus I should
> not respond to this thread!
>
> Stephen
> (this is an experiment to see if we can focus on one particular
> discussion element at a time)
>
>
More information about the lambda-dev
mailing list