It would be nice to extend enumarations by introducing the `step` keyword and 
binary enumerators. I'm basing this proposal on how enumerations are 
implemented in the PureBasic language, so I'll just paste a few examples taken 
from its documentation:

[https://www.purebasic.com/documentation/reference/enumerations.html](https://www.purebasic.com/documentation/reference/enumerations.html)

The `step` keywords would allow to adjust the step for each new constant found 
in the enumeration:
    
    
    Enumeration 20 Step 3
      #GadgetInfo ; will be 20
      #GadgetText ; will be 23
      #GadgetOK   ; will be 26
    EndEnumeration

Binary enumarators are practical for working with flags:
    
    
    EnumerationBinary
      #Flags1 ; will be 1
      #Flags2 ; will be 2
      #Flags3 ; will be 4
      #Flags4 ; will be 8
      #Flags5 ; will be 16
    EndEnumeration

I've found these enumeration variants quite practical to use, so I was 
wondering if something similar could be added to Nim core language.

>From what I gathered from the Nim documentation, currently this can only be 
>achieved by manually specifying the step values for each ordinal value field — 
>i.e. unless I'm missing out some obvious way to do this.

Reply via email to