Olivier Lefevre schrieb:
> Johannes Luber wrote:
>> Thanks for the enlightenment - this is more an obscure Java feature than
>> something a neophyte would ever consider. Micheal's C# translation shows
>> that Java lacks clarity unnecessarily.
>
> I disagree on both counts. Anonymous classes are an oft-used technique
> (e.g., in callbacks) that just takes a little getting used to. As a
> former colleague of mine said, you don't give a name to each sock in
> your drawers, so why should you have to declared a new named class every
> time to want to instantiate an interface or make a minor change to a
> concrete class?
>
> Nothing is forcing you to use anonymous classes either. You can do what
> Michael did in Java just as well:
>
> class MyToken {
>
> static Set<String, String> legalOptions = new HashSet<String, String>();
>
> static { legalOptions.add(defaultOption); }
>
> ...
> }
>
> Thus, if anything (or, rather, anyone) you should single out Ter, not Java,
> for lacking clarity, as it was his choice to do it this way.
Oh - I'm not that familiar with Java beyond what my introductory course
taught me. Anonymous classes weren't on the list. I have only heard that
anon classes are used as delegate replacements but never looked into the
claim.
> > 1. C# has no built-in Set type so you may use a list or dictionary etc.
> > Just use same value for key and value.
>
> That is indeed how Java's HashSet is implemented.
Interesting!
Johannes
_______________________________________________
antlr-dev mailing list
[email protected]
http://www.antlr.org:8080/mailman/listinfo/antlr-dev