Re: [Vala] Minor features request (about structs and enums)



Michael 'Mickey' Lauer wrote:
Another feature that might be out of context, and I don't know if its
implemented but nor Google nor the people at the IRC channel have been
able to answer me, is enum iteration.

foreach ((what type?) item in MyEnum) { ... }

That's not possible indeed. It might be handy, please open a bug ticket.
There's another bug report requesting a to_string () method for the enums that will be nice to have too

I was also thinking on implementing a enumflags keyword that acts like enum, but shift bits instead of increasing the value. so you can do:

enumflag Mode {
 READ
 WRITE
}

MyOpen (Mode.READ | Mode.WRITE);

What do you think about adding this new keyword? The thing will be good when using bitflags so you dont have to use an enum hardcoding the values in a manual way:

enum Mode {
READ=1,
WRITE=2
...4, 8, 16, 32...
}


--pancake



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]