I don't think you understand the typesafe enumeration.

Your Perl example is exactly the same as your old Java example. This is not about some syntax short cut. The new Java way defines a new enum type, which only has four valid values: MENU_FILE, MENU_EDIT, MENU_FORMAT, MENU_VIEW. It does not define four variables as you sort of indicated. The new Java enumeration is more like Pascal enumeration, it is a type, and any variable has that type can only have one of the four enumerated values. That is why they call it "typesafe".

In Pascal, it also supports the ordering of those four values. Not sure Java does that.

A better example of data is:

enum int (SUN, MON, TUE, WEN, THU, FRI, SAT);

and later you would be able to evaluate something like SAT > TUE.

Perl is a great language, but hey, Java is also great! Besides it is always a nice thing to see a language evolve, and advance, doesn't matter whether it is Perl or Java.


In reply to Re: J2SE 5.0 new features are just sugar from Perl (and other similar languages). by pg
in thread J2SE 5.0 new features are just sugar from Perl (and other similar languages). by gmpassos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":