Re: Compile time data structure

2013-09-20 Thread Dicebot
On Friday, 20 September 2013 at 06:20:09 UTC, Ali Çehreli wrote: On 09/19/2013 04:32 AM, Dicebot wrote: > Some obvious catches: Thank you. I have made those changes except the following one. > Variadic template arg chapter should probably mention "variadic args of > length 1" idiom used to hav

Re: Compile time data structure

2013-09-19 Thread Ali Çehreli
On 09/19/2013 04:32 AM, Dicebot wrote: > Some obvious catches: Thank you. I have made those changes except the following one. > Variadic template arg chapter should probably mention "variadic args of > length 1" idiom used to have parameter accepting types, values and > aliases at once. Could

Re: Compile time data structure

2013-09-19 Thread Ali Çehreli
On 09/19/2013 12:53 PM, H. S. Teoh wrote: > I hope you're > thoroughly confused and utterly perplexed by now No, because you explained it very well. :) > readers should instead be directed to std.traits Indeed, I will add some :) of this information to the Traits chapter which comes later in

Re: Compile time data structure

2013-09-19 Thread Ali Çehreli
On 09/19/2013 12:12 PM, Marek Janukowicz wrote: > (why is your book not linked on dlang.org? It will appear there once the translation is complete. > how do I create a tuple at compile time if I'm getting > information I want to put into it in a foreach? All the > examples I found create a tupl

Re: Compile time data structure

2013-09-19 Thread H. S. Teoh
On Thu, Sep 19, 2013 at 09:12:10PM +0200, Marek Janukowicz wrote: > Ali Çehreli wrote: [...] > > As far as I know, static foreach is only for tuples (or TypeTuples). > > If you can generate the AA as a tuple, then the foreach will be > > evaluated at compile time. > > I read your articles about tu

Re: Compile time data structure

2013-09-19 Thread H. S. Teoh
On Thu, Sep 19, 2013 at 12:46:39AM -0700, Ali Çehreli wrote: > On 09/17/2013 07:26 PM, H. S. Teoh wrote: > > > On Wed, Sep 18, 2013 at 04:12:01AM +0200, John Colvin wrote: > >> On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: > >>> As far as I know, static foreach is only for tu

Re: Compile time data structure

2013-09-19 Thread Marek Janukowicz
Ali Çehreli wrote: > On 09/16/2013 01:24 PM, Marek Janukowicz wrote: > > >static string[string] columns () { > // ... > >} > > Although the function itself is static, it returns a dynamic value. > > > foreach( attr, col; columns() ) { > >__traits(getMember, me, attr) =

Re: Compile time data structure

2013-09-19 Thread Dicebot
On Thursday, 19 September 2013 at 07:46:41 UTC, Ali Çehreli wrote: I have just published two chapters that present tuples and TypeTuple sufficiently-completely and sufficiently-consistently (of course, according to me ;) ): Tuples: http://ddili.org/ders/d.en/tuples.html More Templates:

Re: Compile time data structure

2013-09-19 Thread Ali Çehreli
On 09/17/2013 07:26 PM, H. S. Teoh wrote: > On Wed, Sep 18, 2013 at 04:12:01AM +0200, John Colvin wrote: >> On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: >>> As far as I know, static foreach is only for tuples (or TypeTuples) >> >> TypeTuples are tuples. Sortof. We really ne

Re: Compile time data structure

2013-09-17 Thread H. S. Teoh
On Wed, Sep 18, 2013 at 04:12:01AM +0200, John Colvin wrote: > On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: > >As far as I know, static foreach is only for tuples (or TypeTuples) > > TypeTuples are tuples. Sortof. We really need to get that whole > situation sorted Not

Re: Compile time data structure

2013-09-17 Thread John Colvin
On Wednesday, 18 September 2013 at 01:24:37 UTC, Ali Çehreli wrote: As far as I know, static foreach is only for tuples (or TypeTuples) TypeTuples are tuples. Sortof. We really need to get that whole situation sorted

Re: Compile time data structure

2013-09-17 Thread Ali Çehreli
On 09/16/2013 01:24 PM, Marek Janukowicz wrote: >static string[string] columns () { // ... >} Although the function itself is static, it returns a dynamic value. > foreach( attr, col; columns() ) { >__traits(getMember, me, attr) = typeof(__traits(getMember, me, > attr)).ini

Re: Compile time data structure

2013-09-16 Thread Marek Janukowicz
Ali Çehreli wrote: > Could you please provide complete code. Sure. This is of course stripped down just for demonstration purposes: struct Attr { string name; } mixin template Model() { static string[string] columns () { string[string] cols; alias type = typeof(this); // Basica

Re: Compile time data structure

2013-09-15 Thread Ali Çehreli
Could you please provide complete code. Thank you, Ali

Compile time data structure

2013-09-15 Thread Marek Janukowicz
I need to gather some data in compile time basing on UDA. struct Attr { string name; } mixin template Model() { static string[string] columns () { string[string] cols; alias type = typeof(this); // Basically - get all members with @Attr UDA and build AA out of those foreach(