| Thread overview | ||||||
|---|---|---|---|---|---|---|
|
March 10, 2008 Feature request: with for enums | ||||
|---|---|---|---|---|
| ||||
I would like to be able to do
enum MyEnum
{
first, second, third, fourth, fifth, sixth, seventh eighth
}
MyEnum[100] table =
[
MyEnum.first,
MyEnum.second,
MyEnum.eighth,
MyEnum.first,
...
];
without all that ridiculous qualifying. Maybe it's possible to do that already, but if so, I haven't found anything which compiles. I would have expected the following to work, but it doesn't:
with(MyEnum) MyEnum[100] table =
[
first,
second,
eighth,
first,
...
];
Apparently, "with" only works with structs and classes - not enums. I'm wondering if this can be extended and made to work also with enums?
(...or if there's something I've missed, someone please tell me).
| ||||
March 10, 2008 Re: Feature request: with for enums | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Janice Caron | On Mon, 10 Mar 2008 09:54:12 +0000, Janice Caron wrote: [..]
> with(MyEnum) MyEnum[100] table =
> [
> first,
> second,
> eighth,
> first,
> ...
> ];
>
> Apparently, "with" only works with structs and classes - not enums. I'm wondering if this can be extended and made to work also with enums?
>
> (...or if there's something I've missed, someone please tell me).
What you ask for is not possible yet.
As far as I can remember, Walter thought about adding this kind of feature
(at least for switch).
But I don't think it got much further since there is much other stuff to
do.
| |||
March 10, 2008 Re: Feature request: with for enums | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Janice Caron | Janice Caron wrote: > I would like to be able to do > > enum MyEnum > { > first, second, third, fourth, fifth, sixth, seventh eighth > } > > MyEnum[100] table = > [ > MyEnum.first, > MyEnum.second, > MyEnum.eighth, > MyEnum.first, > ... > ]; > > without all that ridiculous qualifying. Maybe it's possible to do that > already, but if so, I haven't found anything which compiles. I would > have expected the following to work, but it doesn't: > > with(MyEnum) MyEnum[100] table = > [ > first, > second, > eighth, > first, > ... > ]; > > Apparently, "with" only works with structs and classes - not enums. > I'm wondering if this can be extended and made to work also with > enums? > > (...or if there's something I've missed, someone please tell me). I think using enums without fully qualifying them is a planned feature for D2. At least it says that in the first slides: http://d.puremagic.com/conference2007/speakers.html (see Enum Member Lookup Rules) So maybe with won't be necessary for enums. | |||
March 10, 2008 Re: Feature request: with for enums | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Janice Caron | Janice Caron wrote: > Apparently, "with" only works with structs and classes - not enums. > I'm wondering if this can be extended and made to work also with > enums? > > (...or if there's something I've missed, someone please tell me). This has been requested before, as well: http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=digitalmars.D&artnum=40548 http://www.digitalmars.com/d/archives/digitalmars/D/37925.html -- E-mail address: matti.niemenmaa+news, domain is iki (DOT) fi | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply