Is [] mandatory for array operations?

Robert Jacques sandford at jhu.edu
Thu May 6 22:34:39 PDT 2010


On Fri, 07 May 2010 00:13:04 -0400, Jason House  
<jason.james.house at gmail.com> wrote:
> Robert Jacques Wrote:
>> given
>> real foo(real value) {...}
>> and
>> real[] foo(real[] value) {...}
>>
>> what should happen with the follow line of code:
>>
>> x[] = foo(y[]) + z[];
>
> That can be interpreted in either of the following ways:
>
> foreach(i) x[i] = foo(y[i]) + z[i];
> OR
> auto F = foo(y[]); foreach(i) x[i] = F + z[i];
>
> The 2nd would be a compile error, so it must be the first.

Well, this adds a bunch of complexity, since a combinatorial number of  
statements have to be evaluated and a match picked.

And then there's the ambiguous case:
x[] = foo(y[]);
Which is an example of x[] = y; vs x[] = y[]; problem.


More information about the Digitalmars-d mailing list