How to use destroy and free.

H. S. Teoh hsteoh at quickfur.ath.cx
Wed May 4 21:55:18 UTC 2022


On Wed, May 04, 2022 at 09:46:50PM +0000, forkit via Digitalmars-d-learn wrote:
[...]
> That languages with GC typically give the programmer some control over
> the GC, is evidence that programmers do care (otherwise such features
> would not be needed).
> 
> To deny a programmer the option to release the memory that was GC
> allocated within a particular scope, to be release immediately after
> that scope exits, seems kinda cruel.
[...]

	scope ptr = GC.malloc(size);
	scope(exit) GC.free(ptr);

	... // use ptr however you like until end of scope


T

-- 
It's amazing how careful choice of punctuation can leave you hanging:


More information about the Digitalmars-d-learn mailing list