Thread overview
Why does the rhs of delete have to be lvalue?
Mar 11, 2005
Matthew
Mar 11, 2005
xs0
Mar 11, 2005
Matthew
Mar 11, 2005
Ben Hinkle
Mar 11, 2005
Ilya Minkov
Mar 11, 2005
Walter
Mar 11, 2005
Derek Parnell
Mar 11, 2005
Matthew
Mar 12, 2005
David L. Davis
March 11, 2005

March 11, 2005
Just out of curiosity - when is it a problem?
March 11, 2005
I'm formulating a treatise on why delete should be dropped for removing elements from AAs, and this is making it easier than I'd expected. ;)

"xs0" <xs0@xs0.com> wrote in message news:d0rrqh$1kk8$1@digitaldaemon.com...
> Just out of curiosity - when is it a problem?


March 11, 2005
Doesn't it have to be a reference or pointer to something allocated using 'new' (aside from the AA usage)? I'm not exactly sure what is 'delete'able and what isn't.


March 11, 2005
Matthew wrote:
[nothing but the topic]

I believe because the value is being written to. E.g. when it is a
pointer it gets nulled out.

[though that's probably not what Matthew wants to hear from me. i
apparently don't get the vague hint but seeing this Matthew might want
to explain something to dumbasses such as myself]

[I should have probably considered posting the whole message in the
subject line though]

-eye
March 11, 2005
So the reference can be nulled out. You won't have to write:

    delete p;
    p = null;

which is a common C++ idiom.


March 11, 2005
On Fri, 11 Mar 2005 13:23:04 -0800, Walter wrote:

> So the reference can be nulled out. You won't have to write:
> 
>     delete p;
>     p = null;
> 
> which is a common C++ idiom.

So would it be possible to change the D behaviour such that if the coder used a lvalue, D would null it out, otherwise if the coder did not use an lvalue then D would not attempt to null it out.

Also, this is the sort of thing that needs to be explicitly documented in the official docs.

-- 
Derek Parnell
Melbourne, Australia
12/03/2005 8:55:04 AM
March 11, 2005
"Walter" <newshound@digitalmars.com> wrote in message news:d0t3hr$h0a$1@digitaldaemon.com...
> So the reference can be nulled out. You won't have to write:
>
>    delete p;
>    p = null;
>
> which is a common C++ idiom.

Gotcha. (That just adds grist to my mill, however, ....)

:-)


March 12, 2005
In article <d0qrve$gm9$1@digitaldaemon.com>, Matthew says...
>
Matthew this may seem like a pretty dumb question, but what does RHS stand for? I'm thinking that it stands for "Right Hand Side."

Thanks in advance.

David L.

P.S. When I was in the U.S. Army we had a saying, that "The only dumb question, is the one that wasn't asked."

-------------------------------------------------------------------
"Dare to reach for the Stars...Dare to Dream, Build, and Achieve!"