Thread overview | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
September 22, 2004 Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
void main() { int [][] arr; arr.length = 5; arr[].length = 5; } produce C:\projects\code\foo>dmd allslice.d allslice.d(5): slice expression arr[] is not a modifiable lvalue I'm not sure about the validity of this, but it used to work. Lars Ivar Igesund |
September 22, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | In article <ciropf$2cjt$1@digitaldaemon.com>, Lars Ivar Igesund says... <snip> > arr[].length = 5; <snip> > I'm not sure about the validity of this, but it used to work. What is the defined behaviour of that statement? Stewart. |
September 22, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:ciropf$2cjt$1@digitaldaemon.com... > void main() > { > int [][] arr; > arr.length = 5; > arr[].length = 5; > } > > produce > > C:\projects\code\foo>dmd allslice.d > allslice.d(5): slice expression arr[] is not a modifiable lvalue > > I'm not sure about the validity of this, but it used to work. It used to compile, but I don't think it ever worked. |
September 22, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message
> news:ciropf$2cjt$1@digitaldaemon.com...
>
>>void main()
>>{
>> int [][] arr;
>> arr.length = 5;
>> arr[].length = 5;
>>}
>>
>>produce
>>
>>C:\projects\code\foo>dmd allslice.d
>>allslice.d(5): slice expression arr[] is not a modifiable lvalue
>>
>>I'm not sure about the validity of this, but it used to work.
>
>
> It used to compile, but I don't think it ever worked.
>
>
Fair enough, but should it work? Is it a bug?
Lars Ivar Igesund
|
September 22, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | On Wed, 22 Sep 2004 20:10:50 +0100, Lars Ivar Igesund <larsivar@igesund.net> wrote: > Walter wrote: > >> "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message >> news:ciropf$2cjt$1@digitaldaemon.com... >> >>> void main() >>> { >>> int [][] arr; >>> arr.length = 5; >>> arr[].length = 5; >>> } >>> >>> produce >>> >>> C:\projects\code\foo>dmd allslice.d >>> allslice.d(5): slice expression arr[] is not a modifiable lvalue >>> >>> I'm not sure about the validity of this, but it used to work. >> >> >> It used to compile, but I don't think it ever worked. >> >> > > Fair enough, but should it work? Is it a bug? What do you think it should do? Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ |
September 23, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:ciserb$2q3b$1@digitaldaemon.com... > Walter wrote: > > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:ciropf$2cjt$1@digitaldaemon.com... > > > >>void main() > >>{ > >> int [][] arr; > >> arr.length = 5; > >> arr[].length = 5; > >>} > >> > >>produce > >> > >>C:\projects\code\foo>dmd allslice.d > >>allslice.d(5): slice expression arr[] is not a modifiable lvalue > >> > >>I'm not sure about the validity of this, but it used to work. > > > > > > It used to compile, but I don't think it ever worked. > > > > > > Fair enough, but should it work? No. It has about as much meaning as: &(3 + 4) > Is it a bug? In the code, yes. The compiler correctly diagnoses it now. |
September 23, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
> "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message
> news:ciserb$2q3b$1@digitaldaemon.com...
>
>>Walter wrote:
>>
>>
>>>"Lars Ivar Igesund" <larsivar@igesund.net> wrote in message
>>>news:ciropf$2cjt$1@digitaldaemon.com...
>>>
>>>
>>>>void main()
>>>>{
>>>> int [][] arr;
>>>> arr.length = 5;
>>>> arr[].length = 5;
>>>>}
>>>>
>>>>produce
>>>>
>>>>C:\projects\code\foo>dmd allslice.d
>>>>allslice.d(5): slice expression arr[] is not a modifiable lvalue
>>>>
>>>>I'm not sure about the validity of this, but it used to work.
>>>
>>>
>>>It used to compile, but I don't think it ever worked.
>>>
>>>
>>
>>Fair enough, but should it work?
>
>
> No. It has about as much meaning as:
>
> &(3 + 4)
>
>
I don't agree. arr[] means all the elements in the array (according to
the spec). Then arr[] should mean all the arrays when arr is two-dimensional, and length is a valid property of these arrays. Since this quite probably won't scale up, I can accept it if it's wrong, but the spec allows it (as it is now).
Lars Ivar Igesund
|
September 24, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:civ2pc$1r8c$1@digitaldaemon.com... > Walter wrote: > > > "Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:ciserb$2q3b$1@digitaldaemon.com... > > > >>Walter wrote: > >> > >> > >>>"Lars Ivar Igesund" <larsivar@igesund.net> wrote in message news:ciropf$2cjt$1@digitaldaemon.com... > >>> > >>> > >>>>void main() > >>>>{ > >>>> int [][] arr; > >>>> arr.length = 5; > >>>> arr[].length = 5; > >>>>} > >>>> > >>>>produce > >>>> > >>>>C:\projects\code\foo>dmd allslice.d > >>>>allslice.d(5): slice expression arr[] is not a modifiable lvalue > >>>> > >>>>I'm not sure about the validity of this, but it used to work. > >>> > >>> > >>>It used to compile, but I don't think it ever worked. > >>> > >>> > >> > >>Fair enough, but should it work? > > > > > > No. It has about as much meaning as: > > > > &(3 + 4) > > > > > > I don't agree. arr[] means all the elements in the array (according to the spec). Then arr[] should mean all the arrays when arr is two-dimensional, and length is a valid property of these arrays. Since this quite probably won't scale up, I can accept it if it's wrong, but the spec allows it (as it is now). I would like this to work too but i see it as an array operation and these are not implemented yet, but if Walter said it has no meaning than maybe it wouln't work even when we get array operations. > Lars Ivar Igesund |
September 24, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lars Ivar Igesund | In article <civ2pc$1r8c$1@digitaldaemon.com>, Lars Ivar Igesund says... <snip> >> No. It has about as much meaning as: >> >> &(3 + 4) > > I don't agree. arr[] means all the elements in the array (according to the spec). It means an array consisting of all the elements in the array. > Then arr[] should mean all the arrays when arr is two-dimensional, and length is a valid property of these arrays. That applies to values, not to properties. Only when arr[] is the lvalue is it a slice assignment. But it isn't - arr[].length is. Indeed, if it meant the length of each element, it would create a confusing inconsistency: int[][5] x; x[].length = 10; writef(x[].length); > Since this quite probably won't scale up, I can accept it if it's wrong, but the spec allows it (as it is now). Allows what exactly? Stewart. |
September 24, 2004 Re: Slice problem in DMD 0.102 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | "Stewart Gordon" <Stewart_member@pathlink.com> wrote in message news:cj125g$h1$1@digitaldaemon.com... > In article <civ2pc$1r8c$1@digitaldaemon.com>, Lars Ivar Igesund > says... > <snip> > >> No. It has about as much meaning as: > >> > >> &(3 + 4) > > > > I don't agree. arr[] means all the elements in the array > > (according to the spec). > > It means an array consisting of all the elements in the array. > > Then arr[] should mean all the arrays when arr is two-dimensional, and length is a valid property of these arrays. > > That applies to values, not to properties. Only when arr[] is the lvalue is it a slice assignment. But it isn't - arr[].length is. Indeed, if it meant the length of each element, it would create a confusing inconsistency: Now i feel stupid for what i wrote in response to Lars Ivar Igesund, i wasn't thinking! > int[][5] x; > x[].length = 10; > writef(x[].length); > > > Since this quite probably won't scale up, I can accept it if it's wrong, but the spec allows it (as it is now). > > Allows what exactly? > > Stewart. > > |
Copyright © 1999-2021 by the D Language Foundation