digitalmars.D - Feature request: with for enums
- Janice Caron (28/28) Mar 10 2008 I would like to be able to do
- Moritz Warning (7/20) Mar 10 2008 What you ask for is not possible yet.
- Ary Borenszweig (6/40) Mar 10 2008 I think using enums without fully qualifying them is a planned feature
- Matti Niemenmaa (6/11) Mar 10 2008 This has been requested before, as well:
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).
Mar 10 2008
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.
Mar 10 2008
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.
Mar 10 2008
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
Mar 10 2008









Moritz Warning <moritzwarning _nospam_web.de> 