www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Slice problem in DMD 0.102

reply Lars Ivar Igesund <larsivar igesund.net> writes:
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
Sep 22 2004
next sibling parent Stewart Gordon <Stewart_member pathlink.com> writes:
In article <ciropf$2cjt$1 digitaldaemon.com>, Lars Ivar Igesund says...
<snip>
   arr[].length = 5;

 I'm not sure about the validity of this, but it used to work.

What is the defined behaviour of that statement? Stewart.
Sep 22 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"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.
Sep 22 2004
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
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
Sep 22 2004
next sibling parent Regan Heath <regan netwin.co.nz> writes:
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/
Sep 22 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"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.
Sep 22 2004
parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
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
Sep 23 2004
next sibling parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"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

Sep 24 2004
prev sibling parent reply Stewart Gordon <Stewart_member pathlink.com> writes:
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.
Sep 24 2004
parent "Ivan Senji" <ivan.senji public.srce.hr> writes:
"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.

Sep 24 2004