Small code review

Jonathan M Davis jmdavisProg at gmx.com
Mon Jun 18 16:24:41 PDT 2012


On Monday, June 18, 2012 23:41:01 mist wrote:
> Subj: http://dpaste.dzfl.pl/dfab7219
> 
> I wanted to code a small extension to phobos typetuple module to
> extend basic available operations on type tuples more on par with
> std.algorithm ones. I don't have enough practice in
> metaprogramming "D way" though and would gladly listen any
> recommendations in both improving code style and possible ways to
> implement similar things in shorter and more canonical way.

Stylistically-speaking, template parameters should follow the same 
capatilization rules as everything else. If they represent types, then they 
should be PascalCase. Everything else is camelCased. And in the cases where 
it's not known (as might be the case with an alias), camelCasing is used. 
Also, if an eponymous template is going to resolve to a type it should be 
PascalCased, and if it's going to resolve to something else, it should be 
camelCased.

As for what your stuff is doing, I don't see anything blatantly wrong with it, 
but I question the wisdom of hoving filterNum be part of filter. It _is_ doing 
something similar to filter, but it's distinctly different.

You might want to take a look at std.typelist:

https://github.com/D-Programming-Language/phobos/blob/master/std/typelist.d

It's a rather old module which is not actually included in the Phobos build 
right now (I guess that it never quite made it in, and I'm not quite sure what 
we're going to do with it). It probably does some of the sort of stuff that 
you're looking for, though it takes a very different approach. If it were to be 
fully included as part of Phobos, it would need some updating (e.g. fixing how 
it names its symbols, since it doesn't always follow Phobos' naming 
conventions correctly), but it's probably worth your time to look at it if
you're really looking to manipulate TypeTuples with algorithms.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list