Question about Object.destroy
Lambert Duijst via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Sep 20 11:34:35 PDT 2015
On Sunday, 20 September 2015 at 18:21:52 UTC, Adam D. Ruppe wrote:
> Very simple: destroy(s) (or s.destroy but i prefer destroy(s))
> will set the reference it is passed to null because you aren't
> supposed to use it anymore.
>
> So after calling destroy(s), s is null, so it segfaults when
> you try to use it.
Oh that surprises me a bit, because I read in the list of
deprecated features that delete is deprecated and that the right
thing to do is to use destroy instead.
Also when I print the address of s it gives me some hex number,
but not 0 (null).
I use writeln("Address of s ", &s) to print the address, not sure
if that is correct though.
Before and after the explicit destroy I get the same address,
which is 7FFF549108D8.
Btw I use dmd v2.067 on mac os 10.10.3
Thanks for the quick replies.
More information about the Digitalmars-d-learn
mailing list