Thread overview
delete and CommaExp.
Feb 11, 2006
Dave
Feb 11, 2006
Derek Parnell
Feb 11, 2006
Dave
Feb 11, 2006
Nick
Feb 11, 2006
Dave
Feb 11, 2006
Dave
February 11, 2006
Is this now illegal? As of v0.146 the compiler no longer allows it.

void main()
{
int[] a = new int[10], b = new int[10];
delete a, b; // 'var has no effect in expression (b)
}


February 11, 2006
On Sat, 11 Feb 2006 16:20:53 +1100, Dave <Dave_member@pathlink.com> wrote:

>
> Is this now illegal? As of v0.146 the compiler no longer allows it.
>
> void main()
> {
> int[] a = new int[10], b = new int[10];
> delete a, b; // 'var has no effect in expression (b)
> }

What made you think that the syntax for 'delete' was

   DeleteExpression :: 'delete' <identifier> (',' <identifier>)...

On the other hand, I can't find the formal definition of it anywhere in the D documentation.

-- 
Derek Parnell
Melbourne, Australia
February 11, 2006
"Dave" <Dave_member@pathlink.com> wrote in message news:dsjs7l$ai9$1@digitaldaemon.com...
>
> Is this now illegal? As of v0.146 the compiler no longer allows it.
>
> void main()
> {
> int[] a = new int[10], b = new int[10];
> delete a, b; // 'var has no effect in expression (b)
> }

Delete accepts only one parameter.  What's happening here is that delete binds more tightly than comma, so it's something like writing

delete a;
b;

And no-ops, such as "b;" have been made illegal (as they always have been in the spec but were never implemented).


February 11, 2006
In article <op.s4snk3k56b8z09@ginger.vic.bigpond.net.au>, Derek Parnell says...
>
>On Sat, 11 Feb 2006 16:20:53 +1100, Dave <Dave_member@pathlink.com> wrote:
>
>>
>> Is this now illegal? As of v0.146 the compiler no longer allows it.
>>
>> void main()
>> {
>> int[] a = new int[10], b = new int[10];
>> delete a, b; // 'var has no effect in expression (b)
>> }
>
>What made you think that the syntax for 'delete' was
>
>    DeleteExpression :: 'delete' <identifier> (',' <identifier>)...

C++, and because it worked up until v0.146.

>
>On the other hand, I can't find the formal definition of it anywhere in the D documentation.
>


February 11, 2006
In article <dsjudn$d09$1@digitaldaemon.com>, Jarrett Billingsley says...
>
>"Dave" <Dave_member@pathlink.com> wrote in message news:dsjs7l$ai9$1@digitaldaemon.com...
>>
>> Is this now illegal? As of v0.146 the compiler no longer allows it.
>>
>> void main()
>> {
>> int[] a = new int[10], b = new int[10];
>> delete a, b; // 'var has no effect in expression (b)
>> }
>
>Delete accepts only one parameter.  What's happening here is that delete binds more tightly than comma, so it's something like writing
>
>delete a;
>b;
>
>And no-ops, such as "b;" have been made illegal (as they always have been in the spec but were never implemented).
>

That would explain it.

Thanks,

- Dave


February 11, 2006
In article <dsjvfq$ecp$1@digitaldaemon.com>, Dave says...
>>What made you think that the syntax for 'delete' was
>>
>>    DeleteExpression :: 'delete' <identifier> (',' <identifier>)...
>
>C++, and because it worked up until v0.146.

Well, it never actuall worked in D, so it's a good thing dmd now complains about it. And are you sure it actually works in C++, or does it do the same thing? (I sincerely don't know.)

Nick


February 11, 2006
In article <dskgmo$1fdq$1@digitaldaemon.com>, Nick says...
>
>In article <dsjvfq$ecp$1@digitaldaemon.com>, Dave says...
>>>What made you think that the syntax for 'delete' was
>>>
>>>    DeleteExpression :: 'delete' <identifier> (',' <identifier>)...
>>
>>C++, and because it worked up until v0.146.
>
>Well, it never actuall worked in D, so it's a good thing dmd now complains about it. And are you sure it actually works in C++, or does it do the same thing? (I sincerely don't know.)
>
>Nick
>

No it doesn't work in C++ either.. Sorry, I've been stuck on stupid all week it seems. I'd like to think it's not permanent but others may disagree <g>

- Dave