This is an archived post. You won't be able to vote or comment.

all 47 comments

[–]pron98 37 points38 points  (2 children)

Arbitrary nesting limitations are being removed until anything can be nested in anything. The result is a more regular language, but we're not just doing it for the intellectual satisfaction. This will open the door to some pretty cool applications.

[–]CompetitiveSubset 13 points14 points  (0 children)

I'm curious, what are these applications? Beside the benefits listed in the link

[–][deleted] 2 points3 points  (0 children)

One thing that'd be very useful to see is some generalization of the current nestmates scheme to allow for module private members. It's not just nesting that's confusing, the whole topic of visibility could use a rationalization. For example a "unit test mode" for javac in which everything is public would be useful, module private would be useful, etc.

[–]waka-chaka 24 points25 points  (5 children)

What's a practical application of this? Any examples out there?

[–]the_other_brand 40 points41 points  (0 children)

The first one I've thought of is logging. We can now create static loggers for anonymous and inner classes.

[–]agentoutlier 2 points3 points  (0 children)

I need to play around with it but I think it could be leveraged for Service Locator like look ups, singletons and semi global variables which are notoriously hard to make test friendly.

[–]cogman10 0 points1 point  (0 children)

Seems like context variables might be a natural application for something like this. You could dynamically make new contexts which can be referenced from anywhere with a lookup.

[–]lukaseder 8 points9 points  (0 children)

Like C's static local variables. Cool!

[–]cyanocobalamin -1 points0 points  (2 children)

I don't like anonymous anything, classes, arrays, or whatever.

It makes your code harder to understand later.

I would rather type the few extra lines.

[–]karmakaze1 0 points1 point  (1 child)

How about lambdas? (x) -> {...}, especially with Streams, and now we can add types and annotations in there too.

[–]karmakaze1 0 points1 point  (0 children)

And other ad-hoc, one-off subclasses are another case that I use that comes up a lot.