Transparancy

Stephen Colebourne scolebourne at joda.org
Wed Jul 7 10:52:22 PDT 2010


The latest (6 July) lambda document has big changes to the
"transparancy" features.

- this is still scoped to the lambda
- Outer.this is used for lexical scoping
- return is dropped
- yield is added

The problem with the approach is that it is schizophrenic. The
previous approach with "this" and "return" had a certain consistency
such that it was the same as an inner class. Since this proposal is
*more* like CICE (simplified inner classes), one would have expected
to have seen both "this and "return" remain. Instead "yield" appears
completely at random.

Firstly, the document doesn't really give us enough info on "yield" to
be completely clear, but it sounds like "return" but in a lambda. But
WHY?
- it hasn't made the code more transparent or readable, just different
- its a context keyword, which has negative implications in parsing
and interactions with variables
- it doesn't fit the "simpler inner class" mental model

As is well known, I believe strongly that 'this' should be lexically
scoped. Its just so much the standard for closures in other languages
that IMO it is quite amazing that anything else is actually being
considered.

The only mental model that would justify lambda-scoped 'this' is if
the project were renamed to "shorter syntax for inner classes" (or
CICE) and the syntax adjusted to be something obviously based on inner
classes (ie. just adopt the CICE proposal!!!)

I also strongly oppose the 'yield' keyword. It is an unecessary
addition to the language when the 'return' keyword performs a
similarly suitable role.

The only justification for not using 'return' is a desire to use it
later for long-returns. In the original closure debates I showed many
cases why this was a generally bad idea, as it introduces new
exceptions at the core language level and simply isn't what most users
expect. I thought I had sufficiently proven the case of short-returns
during that debate when the original straw-man was produced. Do I
really have to demonstrate it again?

The new syntax is an offshoot of this change I suspect, but as I've
indicated its the wrong offshoot. The proposal is now a CICE-like
proposal, but in the body of BGGA. This combination makes no
conceptual sense I'm afraid, and is frankly rather a frankenstein
monster.

Stephen


More information about the lambda-dev mailing list