[phobos] More tuple algorithms with std.meta

Philippe Sigaud philippe.sigaud at gmail.com
Mon Sep 27 11:58:39 PDT 2010


On Mon, Sep 27, 2010 at 08:17, Shin Fujishiro <rsinfu at gmail.com> wrote:

> I'm willing to add more tuple algorithms to phobos for easing
> metaprogramming in D.  Here's code and example:
>
>  http://gist.github.com/598659
>
> ----------
> alias staticSort!(
>        q{ a.at!(0).sizeof < b.at!(0).sizeof },
>        staticZip!( Wrap!(int, double, byte),
>                    Wrap!("x", "y", "z")))
>      A;
> pragma(msg, A);
> // tuple(Wrap!(byte,"z"),Wrap!(int,"x"),Wrap!(double,"y"))
> ----------
>
> Built-in tuples have been able to store non-type compile-time entities.
> So, I propose we should rename the current TypeTuple to StaticTuple,
> and gather generic (non-type specific) tuple algorithms into a new
> module: std.meta.
>
> Does it sound good?
>
>
> Shin
>

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.

As for calling TypeTuple a StaticTuple, I prefer to keep TypeTuple. By
convergent evolution, I have lots of template that do similar things to your
and can confirm these are not just an intellectual exercise: as soon as you
transform functions for example, you need to transform their parameters
typetuple. The same for transforming a class/struct inner types, etc.
I also choose to call them staticStuff, but it's becoming a bit
cumbersome... Any idea to simplify the names would be welcome.

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.


Philippe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100927/18ac3e82/attachment.html>


More information about the phobos mailing list