Re: enum options

new topic     » goto parent     » topic index » view thread      » older message » newer message
irv said...

I really hate to bring this up, but...

in converting the GTK library, we are faced with hundreds of enums.

GTK being written in C, they almost always start with 0.

It would be nice if there were a global option to set enums to start at 0, instead of 1. Something like

export enum base 0 
   stuff, 
   nonsense 

Or is there one already, and I just haven't found it?

I understand. It would be an exceptional thing but useful for those that really need it. How about something like ...

with zeroenum 
enum stuff, nonsense 
without zeroenum 
enum foo,bar 
 
? {stuff, nonsense} -- {0,1} 
? {foo,bar} -- {1,2} 
irv said...

And while I'm on the subject ... to be able to do a reverse lookup

I know how you feel. Such a facility would greatly simplify sections in win32lib.
It is not a good idea, generally applied to every enum, because most do not need it and it would add lot's of size overhead to an application. I suspect in v4.x (after v4.0) we will have named enums and enum properties. Something along the lines of ...

enum XOpts  
    Bordered=2, RoundEdge, Colored=5 
 
? XOpts.count -- 3 
? XOpts.min -- 2 
? XOpts.max -- 5 
? XOpts.names -- {"Bordered", "RoundEdge", "Colored"} 
? XOpts.data -- {2,3,5} 
? Bordered.name -- "Bordered" 

But there a significant syntax issues to be worked out yet.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu