Re: nested enum

2016-08-25 Thread Illuminati via Digitalmars-d-learn
On Thursday, 25 August 2016 at 01:37:05 UTC, Mike Parker wrote: On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to

Re: nested enum

2016-08-25 Thread Seb via Digitalmars-d-learn
On Thursday, 25 August 2016 at 11:09:43 UTC, Cauterite wrote: On Thursday, 25 August 2016 at 10:36:21 UTC, Daniel Kozak wrote: Btw, tehre is no need for extra semicolon (`;`) after enum and struct definition Thanks. This forum insists on reminding me every time I write code here. Warning ab

Re: nested enum

2016-08-25 Thread Cauterite via Digitalmars-d-learn
On Thursday, 25 August 2016 at 10:36:21 UTC, Daniel Kozak wrote: Btw, tehre is no need for extra semicolon (`;`) after enum and struct definition Thanks. This forum insists on reminding me every time I write code here.

Re: nested enum

2016-08-25 Thread Daniel Kozak via Digitalmars-d-learn
Btw, tehre is no need for extra semicolon (`;`) after enum and struct definition Dne 25.8.2016 v 12:23 Cauterite via Digitalmars-d-learn napsal(a): On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: Well those other answers aren't wrong, but I envisioned that you'd have multi

Re: nested enum

2016-08-25 Thread Cauterite via Digitalmars-d-learn
On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: Well those other answers aren't wrong, but I envisioned that you'd have multiple categories within your sub-enums and whatnot, so you'd need something more like this: struct A { enum X { one,

Re: nested enum

2016-08-24 Thread Daniel Kozak via Digitalmars-d-learn
Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly what I want. s

Re: nested enum

2016-08-24 Thread Mike Parker via Digitalmars-d-learn
On Wednesday, 24 August 2016 at 23:04:25 UTC, Illuminati wrote: How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly w

nested enum

2016-08-24 Thread Illuminati via Digitalmars-d-learn
How can I create nested enum like structures? instead of Enum.X_Y I would like to access like Enum.X.Y Yet I want it to behave exactly as an enum. I just want to not use _ as .'s are better as they express more clearly what I want.

Re: nested enum like template generator

2013-07-16 Thread JS
On Tuesday, 16 July 2013 at 21:12:36 UTC, Ali Çehreli wrote: On 07/16/2013 02:01 PM, Ali Çehreli wrote: > On 07/16/2013 01:40 PM, JS wrote: > > It would be nice if we had some way to data globally(in module). > > > > e.g., __ctfestore["name"] = value; > > I would expect model-level objects s

Re: nested enum like template generator

2013-07-16 Thread Ali Çehreli
On 07/16/2013 02:01 PM, Ali Çehreli wrote: > On 07/16/2013 01:40 PM, JS wrote: > > It would be nice if we had some way to data globally(in module). > > > > e.g., __ctfestore["name"] = value; > > I would expect model-level objects start their lives after the program > starts running but their

Re: nested enum like template generator

2013-07-16 Thread Ali Çehreli
On 07/16/2013 01:40 PM, JS wrote: > The problem is I can't declare my "global" int variables directly inside > the template. This does make it hard to use the same variable across > multiple functions... > > template A > { > int c; // makes c near useless, can't use it like a normal it... >

Re: nested enum like template generator

2013-07-16 Thread JS
On Tuesday, 16 July 2013 at 14:05:38 UTC, Ali Çehreli wrote: On 07/15/2013 10:51 PM, JS wrote: > On Tuesday, 16 July 2013 at 04:37:33 UTC, Ali Çehreli wrote: >> On 07/15/2013 08:43 PM, JS wrote: >> >> > http://dpaste.dzfl.pl/7c8b0ba9 >> > >> > Why the heck can't we use integers in ctfe's? There

Re: nested enum like template generator

2013-07-16 Thread Ali Çehreli
On 07/15/2013 10:51 PM, JS wrote: > On Tuesday, 16 July 2013 at 04:37:33 UTC, Ali Çehreli wrote: >> On 07/15/2013 08:43 PM, JS wrote: >> >> > http://dpaste.dzfl.pl/7c8b0ba9 >> > >> > Why the heck can't we use integers in ctfe's? There seems to >> be no >> > simple way to create a counter and this

Re: nested enum like template generator

2013-07-16 Thread Ali Çehreli
On 07/15/2013 08:43 PM, JS wrote: > http://dpaste.dzfl.pl/7c8b0ba9 > > Why the heck can't we use integers in ctfe's? That is false: import std.range; import std.algorithm; import std.conv; import std.stdio; string makeCode(int begin, int end) { auto result = appender!string(`enum made = "`

Re: nested enum like template generator

2013-07-16 Thread Dicebot
On Tuesday, 16 July 2013 at 05:51:53 UTC, JS wrote: ... Once again you post a complex and messy snippet and than jump to wrong conclusions. This works: template inc(int i) { enum inc = i + 1; } pragma(msg, inc!3); Integers are treated normally in CTFE/templates, contrary to your last

Re: nested enum like template generator

2013-07-15 Thread JS
On Tuesday, 16 July 2013 at 04:37:33 UTC, Ali Çehreli wrote: On 07/15/2013 08:43 PM, JS wrote: > http://dpaste.dzfl.pl/7c8b0ba9 > > Why the heck can't we use integers in ctfe's? There seems to be no > simple way to create a counter and this is one of the most basic > programming constructs to us

Re: nested enum like template generator

2013-07-15 Thread Ali Çehreli
On 07/15/2013 08:43 PM, JS wrote: > http://dpaste.dzfl.pl/7c8b0ba9 > > Why the heck can't we use integers in ctfe's? There seems to be no > simple way to create a counter and this is one of the most basic > programming constructs to use.. yet with ctfe's it's impossible. > > I'd like each variabl

nested enum like template generator

2013-07-15 Thread JS
http://dpaste.dzfl.pl/7c8b0ba9 Why the heck can't we use integers in ctfe's? There seems to be no simple way to create a counter and this is one of the most basic programming constructs to use.. yet with ctfe's it's impossible. I'd like each variable in the nested structs to be incremented