[phobos] More tuple algorithms with std.meta
Shin Fujishiro
rsinfu at gmail.com
Tue Sep 28 00:50:53 PDT 2010
Philippe Sigaud <philippe.sigaud at gmail.com> wrote:
> I'm willing to review your code. I also feel Phobos should showcase D
> metaprogramming on types. At a minimum, filtering, reducing, scanning
> (reduce with history), rotating and inverting tuples should be there.
Thanks! Please note: D metaprogramming is not only on types, but also
on symbols and compile-time constants - possibly combined with mixins.
I mean, static tuple algorithms should be able to handle tuples composed
of heterogeneous entities: types, symbols and/or constants. It will
allow us to write something like follows in a short, functional style:
Struct!(int, "x", double, "y")
http://gist.github.com/600535
> I decided to separate those acting on typetuple and those acting on
> expression tuples / std.typecons.Tuple.
> My code is here:
>
> http://www.dsource.org/projects/dranges/browser/trunk/dranges/typetuple.d
> http://www.dsource.org/projects/dranges/browser/trunk/dranges/variadic.d
> http://www.dsource.org/projects/dranges/browser/trunk/dranges/tuple.d
>
> If think most templates dealing with type tuples (or rather, template
> arguments tuples) should go in std.typetuple.
> Those acting on expression tuples could go in std.variadic.
I did know them. ;-) I thought of proposing your templates if someone
was interested in this topic. (dranges.templates is interesting, too.)
As for the separation of typetuple and variadic... As I mentioned
above, I think static tuple algorithms should be able to work with
heterogeneous tuples. Limiting algorithms only on types is not a
choice for me.
But it does *not* mean I think the variadic is useless! Note that I'm
talking about compile-time operation on template tuple parameters;
std.variadic algorithms would be definitely useful in run-time code.
variadicMap is especially a gem!
Shin
More information about the phobos
mailing list