Is Perl 6 going to have any support for enumerations? I didn't find the word "enum" among the Perl 6 RFC's.

It can be handy to have a set of related constants. Without type checking or overloading, having the compiler know they are related is not particularly important.

Under Perl 6, we are getting more typing, right? So this might be more interesting.

Also, we can program uses for having them related, such as formatting and reverse-lookup. That is, print "Red" instead of 100 if that's part of a Color enumeration.

—John

Replies are listed 'Best First'.
Re: Enumerations
by perrin (Chancellor) on Dec 17, 2001 at 23:41 UTC
    People often just use hashes for this kind of thing, but they don't give you protection from typos. For that, you can use enum, though it has similar issues to the constant pragma. You can also use something like Tie::SecureHash.
Re: Enumerations
by hakkr (Chaplain) on Dec 17, 2001 at 22:34 UTC

    I use The Enums field type in MySQL a lot and it would certainly be useful to have something that reflects this in Perl.

    It may seem daft but I'd also like to see a boolean datatype for better readabilty and to help migrating programmers.