Preparing for the 0.2 draft
Joshua Bloch
jjb at google.com
Tue Feb 2 17:49:45 PST 2010
Rémi,
On Fri, Jan 29, 2010 at 2:25 PM, Rémi Forax <forax at univ-mlv.fr> wrote:
>
> > True, but I haven't heard *any *arguments in favor of the "transparent
> this"
> > that are in any way applicable to Java. Maybe I'm being dense, but I
> believe
> > it's cargo cult language design. In Java, I believe it would be a
> > gratuitous inconsistency, pure and simple. And I believe it would bite
> us
> > sooner rather than later. If I'm wrong, I'd love to see some compelling,
> > practical examples where having this refer to the enclosing instance is
> > useful (in Java).
> >
>
> 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));
> }
> }
>
Unless I'm missing something, that code doesn't require a "this" at all.
Just leave out the "this.", and the unqualified named priority will refer
to the field that you want. I still haven't seen a compelling example
(though I still have some catching up to do on lambda-dev email).
Josh
Josh
More information about the lambda-dev
mailing list