Automatic Foreach

Janice Caron caron800 at googlemail.com
Sun Apr 27 01:40:22 PDT 2008


On 27/04/2008, janderson <askme at me.com> wrote:
>  I think I prefer:
>
>  foo(array[]);

Your suggestion would still ambiguous even if [] were redeployed.
Bill's wouldn't. Consider

    f(a[]) + g(b[])

Do we mean

    f([x foreach(x:a)]) + g([y foreach(y:b)])

or

    [f(x) + g(b[i]) foreach(i,x:a)]

?

I have to say, I prefer a variation of Bill's syntax. I'd want foreach
at the front, not at the back. Python tries to be more like natural
language, but D wants to be more compiler-friendly (easy to parse). So
I'd want

    [foreach(x:a) expr(x)]



More information about the Digitalmars-d mailing list