View mode: basic / threaded / horizontal-split · Log in · Help
January 29, 2012
delete and MmFile
Hello everybody.
So I heard that `delete' is being deprecated?

If that's true, what can I do to close an MmFile?
Or is there another way to create an MmFile object, other than with `new', so
that it gets destroyed when out of scope?

My problem is, I need to reopen the same file outside an if() block. If the
conditional is entered and I don't delete the MmFile in it, my program will
crash at runtime.
Presumably for trying to map the same file twice.

Thank you.
January 29, 2012
Re: delete and MmFile
"NewName" <b5353166@nwldx.com> wrote in message 
news:jg2du7$2nun$1@digitalmars.com...
> Hello everybody.
> So I heard that `delete' is being deprecated?
>

When delete is gone, you will still be able to destroy class instances with 
'clear' from phobos.  Like delete, it runs the destructor on the class, it 
just doesn't actually free the memory, it leaves it for the gc.
When the destructor is called the resources held by MmFile should be 
released.
January 29, 2012
Re: delete and MmFile
Thanks Daniel.
So clear() is a function thing, so my delete mmf; will look like clear(mmf); am I
right?
January 29, 2012
Re: delete and MmFile
Yes.  clear is in object.d so it will always be available.

"NewName" <b5353166@newldx.com> wrote in message 
news:jg2fdj$2rmk$1@digitalmars.com...
> Thanks Daniel.
> So clear() is a function thing, so my delete mmf; will look like 
> clear(mmf); am I
> right?
>
Top | Discussion index | About this forum | D home