@juancarlospaco:

> I dont like the `EndEnumeration` on Nim.

these are just examples pasted verbatim from another language, the focus is on 
how these keyword could simplify automatic steps in the enumeration values. I 
wouldn't like the enum closing keyword either (I prefer indentation too).

@Stefan_Salewski

> All your issues seems to be mostly relevant when using extern C libs with 
> wrappers.

Yes, that's the case; and probably these proposed enumerations features are 
going to be most useful when writing wrappers and interfacing with external 
libraries. Especially when the enum elements are numerous, and inserting a new 
element in the middle would require rewriting all values manually (whereas 
autogenerated values via `steps` or binary enums would require no manual fixes.

> Nim enums can behave strange when they have holes or start not by zero. I was 
> struggling with that for gintro, but we know that Araq recommends using plain 
> (distinct) int constants for this case.

I've read about it, but I guess that it's unavoidable when working with 
external libraries, some times. The overall idea is to make the syntax 
friendlier when this is needed. But if this was to be counter to the general 
Nim philosophy I'd understand it.

But I wonder then, aren't enums supposed to be helpful also for working with 
bit flags? so you can AND and OR together when handling settings parameters? In 
this case you can't avoid leaving holes in the enumeration. From what I 
understood from reading the documentation (and I might be wrong) the issue with 
having holes in enums is that you can't use some iterators with them if you do 
have holes.

Again, it might then be good to have a special binary enumerator type, which 
would not consider them as holes but expect naturally the progression to be 
that of bit values (1, 2, 4, etc.), without loosing functionality like 
iterators, etc. This could be useful in many contexts, so it might be worth to 
have in core.

> For your flags example, there we can use Nim's set[enum], which works fine, I 
> used that approach in gintro.

Could you please provide a link to gintro, so I can look at your example in its 
context for inspiration? thanks.

Reply via email to