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!


In reply to Re: J2SE 5.0 new features are just sugar from Perl (and other similar languages). by ihb
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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.