Automatic Foreach

Janice Caron caron800 at googlemail.com
Sun Apr 27 01:30:35 PDT 2008


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

The problem is that [] already has a defined meaning.

    struct S
    {
        R opSlice() { ... }
    }

    S array;
    foo(array[]);

should call

    foo(array.opSlice());

so then you'd have to do

    foo(array[][]);

to disambiguate.

Personally, I see absolutely no use for the /existing/ use of [],
whereby array[] means array[0..$]. I won't feel a moment's pang of
regret if this usage were dropped. That would free up [] to be
redeployed for "vector operations".



More information about the Digitalmars-d mailing list