Nice to @Share?
Peter Levart
peter.levart at marand.si
Tue Feb 23 07:32:45 PST 2010
On Tuesday 23 February 2010 14:43:32 David.Moss at ubs.com wrote:
> > By the way, I am very happy with final (or implicit final).
> > When I code and find that I need a non-final local variable,
> > I first try to rewrite the code to avoid to use non-final
> > before trying to use a mutable object.
>
> Where des this leave closures?
>
> i.e.: what would we need to make the following code do what it is meant to:
>
> public class C {
> public #int() getSequenceGenerator(int start, int increment) {
> return #int() {
> int ret = start;
> start += increment;
> return ret;
> };
> }
> }
>
Perhaps, diagonal to what Josh suggested about having special syntax to support producing instances of SAM subclasses, e.g.:
#Callable<String>(String s) {
System.out.println(s);
}
we might need special syntax to support producing instances of function type but with full class-like features:
public class C {
public #int() getSequenceGenerator(final int start, final int increment) {
return new #int() {
int seq = start;
{
try { return seq; } finally { seq += increment; }
}
};
}
}
>
> Kind Regards,
>
> David.
>
Regards, Peter
More information about the lambda-dev
mailing list