Memory allocation purity

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 18:16:13 PDT 2014


On Wed, 14 May 2014 17:00:39 -0700
Walter Bright via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> On 5/14/2014 3:42 PM, Brian Schott wrote:
> > If malloc can never be considered pure, even when hidden behind an
> > allocator,
>
> It cannot be pure as long as it can fail.
>
> > why can it be considered pure when hidden behind the GC?
>
> Because GC failures are not recoverable, so the pure allocation
> cannot fail.

Then we should create a wrapper for malloc which throws a MemoryError when
malloc fails. Then malloc failures would be the same as GC failures.

- Jonathan M Davis


More information about the Digitalmars-d mailing list