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
making it not that much worse than your Perl way, even though I agree that manually doing several assignments isn't satisfactory.public int MENU_FILE = 0, MENU_EDIT = 1, MENU_FORMAT = 2, MENU_VIEW = 3;
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 /;
Read argumentation in its context!
In reply to Re: J2SE 5.0 new features are just sugar from Perl (and other similar languages).
in thread J2SE 5.0 new features are just sugar from Perl (and other similar languages). by gmpassos
<code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>