WithStatement for enums
Deewiant
deewiant.doesnotlike.spam at gmail.com
Fri May 12 11:35:02 PDT 2006
I don't know about the rest of you, but I, at least, often tend to try to use
enums somehow like this:
--
enum X { A, B, C }
void main() {
X x = A;
}
--
Uh oh! "Undefined identifier A" etc.
This came up a while ago in a switch statement where I was testing the state of
an enum. On a whim, I tried the following:
--
switch (x) with (x) {
case A:
...
...
}
--
Only to get the error "with expressions must be class objects, not 'X'". I
checked the docs and got the added information that structs work, too, but enums
don't.
Funnily enough, this is the only case I can recall when I've ever wanted to use
the with statement, and surely enough it doesn't work. Typical. <g>
How about it? Why not make WithStatement work with enums, in the manner shown
above? I, for one, would find it handy.
More information about the Digitalmars-d
mailing list