Transparancy
Pavel Minaev
int19h at gmail.com
Wed Jul 7 12:59:31 PDT 2010
On Wed, Jul 7, 2010 at 12:47 PM, Neal Gafter <neal at gafter.com> wrote:
> On Wed, Jul 7, 2010 at 12:41 PM, Pavel Minaev <int19h at gmail.com> wrote:
>>
>> > Those who have used them in other languages rarely think of them as a
>> > method body.
>>
>> And again I have to disagree. Most C# programmers, for one, would
>> think of them in precisely that way, and they alone make up a huge
>> part of "those who have used them in other languages", given the
>> popularity of C#.
>
> My experience is exactly the opposite. In C# "this" is inherited from the
> enclosing scope. No members are inherited from the delegate object type
> into the body of the lambda expression.
This doesn't mean that C# programmers don't think of lambdas as
methods. It means that they think of them as methods on the class, in
the body of which the lambda is written (rather than a delegate type)
- but a method nonetheless. Consequently, they expect "return" to work
in the body of the lambda in the same manner as in any other method.
Also, my comments were only with respect to the meaning of (and
restrictions on) "return". The meaning of "this" is a separate,
albeit related, issue. I personally don't like how it refers to the
lambda object itself in the proposal, but at the same time I see how
it can make some sense given existing Java semantics for anonymous
inner classes, and the obvious parallels between them and lambdas. So
I have no clear _objective_ position on this issue, and wouldn't want
to argue either for or against it on a ground as shaky as a mere
personal preference.
More information about the lambda-dev
mailing list