Re: Enum?

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jeremy Cowgar wrote:
> Etc... This is fine, but what if you want to add a new element and not at the
> end? I am sure we've all done it. Well, I borrowed a good thing from other
> languages
> called an enum (enumeration)... I've done the code already but have not
> committed.
> What do you think?
> 
> }}}
<eucode>
> global enum D_NAME, D_ATTRIBUTES, D_SIZE, ...
> global enum PERSON_NAME, PERSON_AGE=5, PERSON_DOB, PERSON_EMAIL
> 
> printf(1, "name=%d, attributes=%d, size=%d\n", {
>     D_NAME, D_ATTRIBUTES, D_SIZE})
> printf(1, "person_name=%d, age=%d, dob=%d, email=%d\n", {
>     PERSON_NAME, PERSON_AGE, PERSON_DOB, PERSON_EMAIL})
> 
> -- name=1, attributes=2, size=3
> -- person_name=1, age=5, dob=6, email=7
> </eucode>
{{{

> 
> An enum is not a new type, it emits a constant. They can be local or global.
> I think it has a lot of benefit but wanted to get community input.
> 
> --
> Jeremy Cowgar
> <a href="http://jeremy.cowgar.com">http://jeremy.cowgar.com</a>

I think this is a very good idea. This seems like a relatively safe change to
make, as it only affects the front-end. With something like this in the
language,
I think we could stop worrying about how/whether to implement structures, as
this
pretty much takes care of that.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu