On Wed, Mar 31, 2010 at 21:21, Adam D. Ruppe <[email protected]>wrote:
> On Wed, Mar 31, 2010 at 09:03:10PM +0200, Philippe Sigaud wrote: > > Cool, I wasn't sure it'd work. Now we know what this new trait is for :) > > It is slightly different than my old code: the getPlainName helper function > is not required with the __trait. (It truncated the string at the first > paren, since stringof returns the arguments too, whereas identifier does > not). > I get it. > > I think it would be a good idea to get a nice overview doc written up on > template idioms - things like this, how to use the isSomeString, etc, > templates in std.traits to work the constraints, and so on. > Or the way to sneak arrays as template parameters... Oh yes. I'd be willing to participate, but I'm also waiting to see what Andrei says in his book. I recently made a template to bind template parameters, and another to determine the 'arity' of a template (no param, 1, etc.). The latter was after discovering that if an alias parameter is a template, the .stringof gives the entire signature : parameters, constraints, etc. I'm discovering something new every week and I have the impression my knowledge of templates is ... kaleidoscopic : lots of colorful parts, no global vision. > Another one in pretty.d I hit was taking a ParameterTypeTuple and using it > to expand the runtime args array. At first, I used a list of static if > T.length == 1, and manually written it out. Today, I changed it to a CTFE > function returning a string to mix on, which sucks less, but still feels > weird. > I still feel wrong when I'm using CTFE. That's too bad, because with the recent leaps in the CTFE perimeter Don made, CTFE has become a very powerful tool indeed. Having a nice overview document would be good to save time and make this > kind of code prettier. Maybe I'll write one to get started then post it to > the group for additions and improvements. Don't have the time today though. > A document, or a wiki page. But to start things and get a little attention, a discussion here is better. Philippe
