Preparing for the 0.2 draft
Rémi Forax
forax at univ-mlv.fr
Fri Jan 29 14:47:25 PST 2010
Le 29/01/2010 23:33, Alex Blewitt a écrit :
> On 29 Jan 2010, at 22:25, Rémi Forax <forax at univ-mlv.fr> wrote:
>
>> public class AuthGroup {
>> private final List<User> userList;
>> private final int priority;
>> ...
>> public List<User> getAuthorizedUsers() {
>> //filter works like filter in Python
>> return userList.filter(#(User user) (user.getPriority() >=
>> this.priority));
>> }
>> }
>
> Note that you could equally write:
>
> return userList.filter(#(User user) (user.getPrioriry() >=
> AuthGroup.this.priority));
>
> It's not that the lambda should be prevented from accessing a
> surrounding instances fields; rather, the desire is to find out
> examples where "this" might refer to varsity associated with the
> lambda itself, such as if it extends a SAM class instead of an interface.
Technically, a lambda is converted to a SAM type.
If you want to access to the current object, you should not use a lambda
(which is a function)
and use an anonymous class (which define an object).
>
> In the interim, allowing explicit uses of qualified this whilst
> leaving the unqualified this as a syntax error allows the point to be
> debated further without blocking the goal you described above.
Designing a language is hard.
Designing a language with temporary syntax is worst.
>
> Alex
>
Rémi
More information about the lambda-dev
mailing list