Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 08, 2008 Eval order, bug or design decision? | ||||
---|---|---|---|---|
| ||||
int[] a1, a2; // .... int idx = 0; a1[idx] = a2[idx++]; In Java this has another result like in D. Java will evaluate from left to right, D does the increment befor doing the assignment, so the copied values go into different fields. Is this a bug or design decision? |
March 08, 2008 Re: Eval order, bug or design decision? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | "Frank Benoit" <keinfarbton@googlemail.com> wrote in message news:fqubu4$2d2e$1@digitalmars.com... > int[] a1, a2; > // .... > > int idx = 0; > a1[idx] = a2[idx++]; > > In Java this has another result like in D. > Java will evaluate from left to right, D does the increment befor doing > the assignment, so the copied values go into different fields. > > Is this a bug or design decision? http://www.digitalmars.com/d/1.0/expression.html Very first section. It's illegal code but it's up to the compiler to detect it or not. I guess you could file a bug about it as "accepts-invalid". |
March 08, 2008 Re: Eval order, bug or design decision? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | Frank Benoit wrote:
> int[] a1, a2;
> // ....
>
> int idx = 0;
> a1[idx] = a2[idx++];
>
> In Java this has another result like in D.
> Java will evaluate from left to right, D does the increment befor doing the assignment, so the copied values go into different fields.
>
> Is this a bug or design decision?
Currently order of evaluation dependencies are illegal in D. Did you run across it in some Java code?
|
March 08, 2008 Re: Eval order, bug or design decision? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Walter Bright schrieb: > Frank Benoit wrote: >> Is this a bug or design decision? > > Currently order of evaluation dependencies are illegal in D. Did you run across it in some Java code? Yes, see 2. + 3. change http://www.dsource.org/projects/dwt-linux/changeset/204%3A8ab2f71515ba My eyes will be more sensible for this patterns now :) |
March 09, 2008 Re: Eval order, bug or design decision? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit | Frank Benoit wrote:
> Walter Bright schrieb:
>> Currently order of evaluation dependencies are illegal in D. Did you run across it in some Java code?
>
> Yes, see 2. + 3. change
> http://www.dsource.org/projects/dwt-linux/changeset/204%3A8ab2f71515ba
>
> My eyes will be more sensible for this patterns now :)
My old C eyes are pretty sensitive to that, too. But it's also clear that D should move to a defined left-to-right order-of-evaluation semantic.
|
Copyright © 1999-2021 by the D Language Foundation