Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 15/11/2011 22:56, bearophile wrote: Johannes Totz: class EnumType { int x; alias x this; this(int i) { x = i; } void opCall(int i) { } } enum X : EnumType { a = EnumType(1), b = 2 } Error

Re: enum for beginners

2011-11-15 Thread bearophile
Johannes Totz: > class EnumType > { > int x; > alias x this; > > this(int i) > { > x = i; > } > > void opCall(int i) > { > } > } > > enum X : EnumType > { > a = EnumType(1), > b = 2 > } > > > Errors range are always

Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 15/11/2011 20:37, Mike Wey wrote: On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this does not: enum X : string { a = "a", // Error

Re: enum for beginners

2011-11-15 Thread Mike Wey
On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this does not: enum X : string { a = "a", // Error: Integer constant expression expected

Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 15/11/2011 16:30, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 11:15:01 -0500, Johannes Totz wrote: On 15/11/2011 15:56, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:55:44 -0500, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz wrote: Ah, when I c

Re: enum for beginners

2011-11-15 Thread Steven Schveighoffer
On Tue, 15 Nov 2011 11:15:01 -0500, Johannes Totz wrote: On 15/11/2011 15:56, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:55:44 -0500, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz wrote: Ah, when I compile on the command line with: dmd -g -debug ma

Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 15/11/2011 15:56, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:55:44 -0500, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz wrote: Ah, when I compile on the command line with: dmd -g -debug main.d main.d(6): Error: enum main.X base type must be of int

Re: enum for beginners

2011-11-15 Thread Steven Schveighoffer
On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz wrote: On 15/11/2011 15:43, Johannes Totz wrote: On 14/11/2011 22:32, Timon Gehr wrote: On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } in

Re: enum for beginners

2011-11-15 Thread Steven Schveighoffer
On Tue, 15 Nov 2011 10:55:44 -0500, Steven Schveighoffer wrote: On Tue, 15 Nov 2011 10:47:22 -0500, Johannes Totz wrote: Ah, when I compile on the command line with: dmd -g -debug main.d main.d(6): Error: enum main.X base type must be of integral type, not char[] main.d(8): Error: cann

Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 15/11/2011 15:43, Johannes Totz wrote: On 14/11/2011 22:32, Timon Gehr wrote: On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this d

Re: enum for beginners

2011-11-15 Thread Johannes Totz
On 14/11/2011 22:32, Timon Gehr wrote: On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this does not: enum X : string { a = "a", // Err

Re: enum for beginners

2011-11-14 Thread Timon Gehr
On 11/14/2011 11:25 PM, Johannes Totz wrote: Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this does not: enum X : string { a = "a", // Error: Integer constan t expression expec

enum for beginners

2011-11-14 Thread Johannes Totz
Hi! I'm having trouble with named typed enums. This works (unnamed): enum : string { a = "a", b = "b" } int main(string[] argv) { writeln(a); return 0; } But this does not: enum X : string { a = "a", // Error: Integer constant expression expected // instead of "a" b