Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
February 11, 2006 delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | 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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | "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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Derek Parnell | 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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jarrett Billingsley | 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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dave | 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 Re: delete and CommaExp. | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick | 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 |
Copyright © 1999-2021 by the D Language Foundation