[Vala] enum values and scopes



Hello list!
When I have an enum like

enum TrackState {
        PLAYING = 0,
        PAUSED,
        STOPPED
}

and do the following
TrackState state = PLAYING;
I'll get an error, because valac does not search for possible values in
the scope of TrackState. Instead I have to write 
TrackState state = TrackState.PLAYING;

To my mind that's not convenient and also not the way c or c++ does it.
In my real world example TrackState lives in a class called GlobalAccess
which is in the namespace Xnoise.

So (provided I don't want to import Xnoise into the default namespace) I
have to write

if (ga.get_track_state() == Xnoise.GlobalAccess.TrackState.PLAYING)
blabal();

that's really not convenient and the worst part of it isn't even the
typing but remembering the complete "path" to the final value.

if (ga.get_track_state() == PLAYING)
would be much more readable, writable and memorizable.
And when you want to use values from a different scope you can still
prefix it.
If I have just requested a feature that has already been discussed a
thousand times, I'm sorry.

regards
andi




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