Re: enum options

new topic     » goto parent     » topic index » view thread      » older message » newer message
Matt Lewis said...
Bernie said...

enum should be perform in the same way that it is used in C.

Why don't you go to a C compiler source code and see how it is done in that code.

The last thing I want to do is to go through the source code for a C-compiler. I'm not sure what purpose this would serve, in any case.

Bernie said...

If it was done this way then translating to compiled C code would be straight forward...

I can't imagine how it would make anything easier when translating to C code.

Bernie said...

...and new users who use C would not be confused.

This suggestion assumes that the most common usage of enums will be for wrapping C code. I doubt this to be the case. And I care more for making euphoria easier for euphoria programmers than for theoretical users coming from another language. They know that they're using a different language. Since we're actually programming in euphoria, we should follow euphoria conventions, and starting at 1 is much more useful. It's really not that difficult to add in the "= 0" to the first enum, if that's the requirement.

If you only need to tweak one or two enums in a program, this approuach is correct. If you have scores of them, it is not correct at all. At least terrbly unpractical.

Matt Lewis said...

Further, I think that the "with base=n" will lead to difficult to maintain code. I think that if you need some weirdness, it's better to explicitly declare it.

Isn't "with base n" explicit? I don't understand. It will also help Basic users, who have an Options Base n directive as well.

Matt Lewis said...

If you're creating a set of bit flags, don't use enums.

Why?

Matt Lewis said...

Use constants. It will be much clearer for everyone reading the code.

Matt

And much more tedious to code. I cannot see how the example Shawn posted is not clear. Could you elaborate? By the ay, nothing prevents you from adding comment marks with an explicit value to the enum.

Comments have a precise purpose in the (any) language: tell reader things a machine doesn't need to know, or in a different way. The language constructs do not need to duplicate one another's functionality, and this applies to coments just as well.

CChris

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

Search



Quick Links

User menu

Not signed in.

Misc Menu