My first email to Walter, ever

Andrej Mitrovic andrej.mitrovich at gmail.com
Sun Jul 7 06:31:08 PDT 2013


On 7/7/13, Peter Alexander <peter.alexander.au at gmail.com> wrote:
> Still looks like half-assed functional programming to me.

Yep I agree.

> Where's the iteration? Why can't I write this?
>
> template allSatisfy(alias F, T...) {
>      foreach(t; T)
>          if (!F!(t))
>              return false;
>      return true;
> }

Also why not be able to write this (yes I know we can use Filter!()
but this is just an example):

template GetIntegrals(Types...)
{
    foreach (T; Types)
    {
        static if (isIntegral!T)
            GetIntegrals ~= T;  // GetIntegrals becomes a typetuple
    }
}

This beats the whole recursive template madness which we always have
to write (again there's the D language, and the "template" language,
just like in C++)

Maybe it would even speed things up not having to recursively
instantiate the template many times.


More information about the Digitalmars-d-announce mailing list