Re: enum and tuples

2013-08-11 Thread Jonathan M Davis
On Sunday, August 11, 2013 07:24:52 captaindet wrote: I'm pretty sure that this is just a bad error message. void main(){ writeln(ok: , ok, ok[0]: , ok[0]); // ok: Tuple!(string, string, string)(one, two, three) ok[0]: one writeln(er: , er, er[0]: , er[0]); // er:

Re: enum and tuples

2013-08-10 Thread Dejan Lekic
On Friday, 9 August 2013 at 21:24:30 UTC, Ali Çehreli wrote: On 08/09/2013 12:41 PM, captaindet wrote: On 2013-08-09 11:36, Ali Çehreli wrote: as I am in the process of revising and translating a Tuples chapter. as a matter of fact, i am checking your website regularly, eagerly awaiting

Re: enum and tuples

2013-08-10 Thread captaindet
I'm pretty sure that this is just a bad error message. void main(){ writeln(ok: , ok, ok[0]: , ok[0]); // ok: Tuple!(string, string, string)(one, two, three) ok[0]: one writeln(er: , er, er[0]: , er[0]); // er: onetwothree er[0]: one } What I expect is happening is that TypeTuples don't

Re: enum and tuples

2013-08-10 Thread Ali Çehreli
On 08/09/2013 10:41 AM, H. S. Teoh wrote: 1) There's the built-in tuple, which is a compiler concept, and basically means any sequential collections of things (for lack of a better word). For example, you can have a sequence of types, like (int, string, float), or a sequence of values, like

enum and tuples

2013-08-09 Thread captaindet
/aggregates. anyhow, i started playing a bit putting them in enums anyway. surprisingly, storing tuples and typetuples in enums is accepted by the compiler. however, while enum tuples seem to behave normal/useful at compile time and run time, enum'ed typetuples don't like compile time, but seem to behave

Re: enum and tuples

2013-08-09 Thread Ali Çehreli
On 08/08/2013 11:16 PM, captaindet wrote: hi, i am still struggling getting to grips with tuples, especially typetuples. Yes, especially TypeTuples. :) typetuples seem to live in a shadow world My feelings! :) Coincidentally, I am struggling with the same question at the moment as I am

Re: enum and tuples

2013-08-09 Thread H. S. Teoh
On Fri, Aug 09, 2013 at 09:36:16AM -0700, Ali Çehreli wrote: On 08/08/2013 11:16 PM, captaindet wrote: hi, i am still struggling getting to grips with tuples, especially typetuples. Yes, especially TypeTuples. :) typetuples seem to live in a shadow world My feelings! :)

Re: enum and tuples

2013-08-09 Thread Jonathan M Davis
On Friday, August 09, 2013 10:41:05 H. S. Teoh wrote: On Fri, Aug 09, 2013 at 09:36:16AM -0700, Ali Çehreli wrote: On 08/08/2013 11:16 PM, captaindet wrote: hi, i am still struggling getting to grips with tuples, especially typetuples. Yes, especially TypeTuples. :)

Re: enum and tuples

2013-08-09 Thread Jonathan M Davis
On Friday, August 09, 2013 01:16:12 captaindet wrote: module demo; import std.stdio, std.typetuple, std.typecons; enum ok = tuple(one, two, three); pragma(msg, ok, , , ok[0]); // Tuple(one, two, three), one enum er = TypeTuple!(one, two, three); // pragma(msg, er); // Error: variable

Re: enum and tuples

2013-08-09 Thread captaindet
On 2013-08-09 11:36, Ali Çehreli wrote: as I am in the process of revising and translating a Tuples chapter. thanks for the reply, Ali. as a matter of fact, i am checking your website regularly, eagerly awaiting the translations of the tuples chapter. and the __traits and the template

Re: enum and tuples

2013-08-09 Thread anonymous
On Friday, 9 August 2013 at 06:16:20 UTC, captaindet wrote: a) if we are not allowed to put typetuples in enums, why is it not an error? [...] enum er = TypeTuple!(one, two, three); FWIW, it's an error in the current git head dmd: Error: cannot cast one to (string, string, string) at

Re: enum and tuples

2013-08-09 Thread Ali Çehreli
On 08/09/2013 12:41 PM, captaindet wrote: On 2013-08-09 11:36, Ali Çehreli wrote: as I am in the process of revising and translating a Tuples chapter. as a matter of fact, i am checking your website regularly, eagerly awaiting the translations of the tuples chapter. and the __traits and

Re: enum of tuples

2012-09-27 Thread Simen Kjaeraas
On 2012-09-27, 00:02, Jonathan M Davis wrote: Classes will not work for the same reason that you can never use a class object as an enum with manifest constants. Has a decision been made as to whether or not this will be possible in the future? -- Simen

Re: enum of tuples

2012-09-27 Thread Jonathan M Davis
On Friday, September 28, 2012 03:56:39 Simen Kjaeraas wrote: On 2012-09-27, 00:02, Jonathan M Davis wrote: Classes will not work for the same reason that you can never use a class object as an enum with manifest constants. Has a decision been made as to whether or not this will be possible

enum of tuples

2012-09-26 Thread Van de Bugger
Hi, I faced a little trouble and can not decide if it is a my mistake, a bug in std library or in compiler… Look: $ cat enum_of_structs.d struct T { int v; int opCmp( T rhs ) { return v == rhs.v ? 0 : ( v rhs.v ? -1 : +1 ); }; }; enum E : T { A = T( 1 ),

Re: enum of tuples

2012-09-26 Thread Van de Bugger
BTW, I use DMD64 D Compiler v2.060 on Fedora 17. ldc2 compiler (LLVM D Compiler LDC trunk, based on DMD v2.059 and LLVM 3.0) produces similar results: $ ldc2 -c -w enum_of_tuples.d enum_of_tuples.d(5): Error: template std.typecons.Tuple!(int,v).Tuple.opCmp does not match any function

Re: enum of tuples

2012-09-26 Thread bearophile
Van de Bugger: Oops. What the problem? I seems one or more bugs. D named enums are adapted from the C language, they were first of all meant to contain simple values like ints or chars. The more complex things you keep trying to put in them, the more bugs you will find :-) People in

Re: enum of tuples

2012-09-26 Thread Jonathan M Davis
On Wednesday, September 26, 2012 23:24:08 bearophile wrote: Van de Bugger: Oops. What the problem? I seems one or more bugs. D named enums are adapted from the C language, they were first of all meant to contain simple values like ints or chars. The more complex things you keep trying to