in reply to J2SE 5.0 new features are just sugar from Perl (and other similar languages).

About enumerations.

old Java way:
public int MENU_FILE = 0; public int MENU_EDIT = 1; public int MENU_FORMAT = 2; public int MENU_VIEW = 3;

I'd write that as

public int MENU_FILE = 0, MENU_EDIT = 1, MENU_FORMAT = 2, MENU_VIEW = 3;
making it not that much worse than your Perl way, even though I agree that manually doing several assignments isn't satisfactory.

Well, Perl already have an easy way to declare a sequence of numbers, so, we don't need a enum word.

Your Perl way isn't satisfactory either though. Keeping track of how many variables/constants you have shouldn't be necessary. That's why I like the enum module. It has nice other features too, such as prefixes and bitmask enumerations.

use enum qw/ :MENU_ FILE EDIT FORMAT VIEW /;

ihb

Read argumentation in its context!

Replies are listed 'Best First'.
Re^2: J2SE 5.0 new features are just sugar from Perl (and other similar languages).
by gmpassos (Priest) on Oct 11, 2004 at 23:37 UTC
    Thanks for your advices. And the module enum show to us how Perl is malleable.

    Graciliano M. P.
    "Creativity is the expression of the liberty".