Too terse and too alien?

Reinier Zwitserloot reinier at zwitserloot.com
Tue Jun 1 08:08:25 PDT 2010


With all due respect, the notion that some syntax form is "not in line with
Java's syntactical pedigree" is trivial and not helpful. Of course it isn't
- it's not legal java code (java6 code, at any rate), because it's for a new
feature that doesn't exist in today's java. If instead you meant that it
doesn't really "feel" like java, even future java, then - well, okay, but
that's just an opinion. I for one think it's particularly elegant but I get
the urge to sigh when I see the syntax for function types. But that's
neither here nor there. The point is: everyone has their own opinion on what
'feels like' java and what 'does not feel like java'. Therefore using that
as an argument (this does not feel like java to me) just means there as 6
billion arguments, each as valid as any other. Perhaps some sort of poll
would help here, though polling in such a way that you get an unbiased
representative sample of the greater java community is probably impossible,
and that's assuming that designing programming language features by popular
vote from the masses is a good idea in the first place.

Lest these threads turn into too much of an endless stream of glorified
meaningless back and forth ("I like it", "it sucks", "I like it", etcetera,
dressed up with nice looking but in the end meaningless feeling-based backup
for these statements), perhaps we can focus on measurable or provable issues
about syntax.

For example, the closure syntax avoids "new" as well as a type name and thus
do not look like objects. Therefore I would posit that letting "this" refer
to the closure is a bad idea, because that's surprising. Also, it seems
trivially true that referring to the object you're in is far more likely to
occur than writing a recursive closure, and the most common case should get
the nicest syntax. Better to find some other way to allow recursion. The
argument then isn't so much "I don't like it", nor "It's just not java", but
instead: "It's confusing because the 'this' syntax hints at object nature
but lack of the 'new' keyword doesn't make this obvious" combined with
"Referring to the enclosing object is more common than recursive closures,
and should therefore get the nicer syntax".

A good thing that var.() has going for it is that it looks visually unique
(which is good, because it turns out invoking closures is a more or less
unique concept too), yet the '.' retains its current universal 'dereference'
meaning. On a purely personal 'taste' note I'm ambivalent; var.() and
var.invoke() are both perfectly fine in my book. So long as it won't be just
"var()" I'm happy. Another thing it has going for it is that the changes to
the grammar required to support it are small. (Contrast to e.g. "var()",
where the required changes to the underlying java parsing tools is gigantic,
as they'll now have to do even more resolution analysis which is already one
of the most complicated aspects of java source parsing).

--Reinier Zwitserloot



On Tue, Jun 1, 2010 at 4:42 PM, Paul Benedict <pbenedict at apache.org> wrote:

> My biggest repulsion is the "anonymous method" syntax. My thoughts on
> the matter haven't changed. A method invocation without a method name
> .() is absolutely confusing and not in line with Java's syntactical
> pedigree. If there's a chance for "invoke" to come back -- or anything
> with a name -- let it come back.
>
> Paul
>
>


More information about the lambda-dev mailing list