digitalmars.D.learn - string enums
- Lodo (18/18) Apr 27 2013 Hi!
- Adam D. Ruppe (12/12) Apr 27 2013 I can't help too much with your problem because I tried it and it
- Namespace (2/21) Apr 27 2013 Works fine for me with dmd >= 2.062
- Lodo (5/6) Apr 27 2013 I'm using dmd 2.059. Maybe I will update it.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (12/14) Apr 27 2013 That works too. Tried with 2.063-devel-f6d55a9-dirty:
Hi!
I'm having some troubles with an enum with base type string.
Here's the code:
enum Type:string
{
DOT="DOT",
ID="ID",
MODULE="MODULE",
SEMICOLON="SEMICOLON",
ERROR="ERROR",
EOF="EOF"
}
For every element of the enum, dmd writes this message two times:
Integer constant expression expected instead of "DOT"
(with "ID", "MODULE", ... instead of "DOT")
Am I doing something wrong?
Thanks in advance.
Lodo
Apr 27 2013
I can't help too much with your problem because I tried it and it
works for me (on my dmd 2.061), but the pattern you're doing
there is actually unneeded:
enum Type {
DOT, ID, MODULE, /* etc ....*/
}
would actually work and you can get a string out of it with
std.conv.to:
import std.conv;
Type t = Type.DOT;
string s = to!string(t);
assert(s == "DOT");
Apr 27 2013
On Saturday, 27 April 2013 at 18:34:24 UTC, Lodo wrote:
Hi!
I'm having some troubles with an enum with base type string.
Here's the code:
enum Type:string
{
DOT="DOT",
ID="ID",
MODULE="MODULE",
SEMICOLON="SEMICOLON",
ERROR="ERROR",
EOF="EOF"
}
For every element of the enum, dmd writes this message two
times:
Integer constant expression expected instead of "DOT"
(with "ID", "MODULE", ... instead of "DOT")
Am I doing something wrong?
Thanks in advance.
Lodo
Works fine for me with dmd >= 2.062
Apr 27 2013
On Saturday, 27 April 2013 at 18:41:45 UTC, Namespace wrote:Works fine for me with dmd >= 2.062I'm using dmd 2.059. Maybe I will update it. I'm using MonoDevelop as IDE. I found that if I try to make an enum of doubles, dmd outputs 36 very complex error messages. I will try to investigate further.
Apr 27 2013
On 04/27/2013 12:02 PM, Lodo wrote:I found that if I try to make an enum of doubles, dmd outputs 36 very complex error messages.That works too. Tried with 2.063-devel-f6d55a9-dirty: enum Type : double { a = 1.5, b = 2.5 } void main() { auto e = Type.min; } Ali
Apr 27 2013









"Adam D. Ruppe" <destructionator gmail.com> 