What I would like to see: private @Getter int x = 5;
I don't really need the C# feature where you can write the getter on location; most getters just return the value, and as long as the API works via a getFoo() call (and not via accessing a public field!) I can always change it later. Incidentally, I may have an announcement to make soon for those who like this idea :P (though IDEA and Netbeans people are going to be a bit disappointed...) On Jul 7, 1:08 pm, Ben Schulz <[email protected]> wrote: > > Looking at JavaFX the story there is completely different. I had to > > write a lot of property binding code in C# lately (would have been the > > same in Java I guess) and seeing that all done with the little keyword > > bind just blows my mind. > > I agree, it's a really cool feature to have in a language that's > focused on GUI-development, after all that's most of what you do. But > it's important to remember that internally it's done with a bunch of > listeners, similar to beans binding just less transparent (or more, > depending on how you look at it). Anyway, my point is that in a > general purpose language you can have the same thing without being too > verbose: > > // Disclaimer: I never actually wrote C# code, I just read some > articles. > private readonly Binding<int> b > = BindingLib.createBinding(=> parent.width - 20); > public readonly int width { get { return b.get(); } } > > I'm pretty sure that expression trees are not powerful enough to > actually return the value of "parent", but you get the idea. > > // less lazy variation (based on the Java with properties > // and expression trees from my dreams). binding would > // keep a weak reference to "this#width" and dispose of > // itself when "this" is collected > private final Binding binding > = BindingLib.createBinding( > this#width, > parent.width - 20 > ); > property int width { public get; private set; } > > With kind regards > Ben --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
