Should GC.malloc be considered 'pure'?

pillsy pillsbury at gmail.com
Sat Jun 11 11:59:55 PDT 2011


== Quote from Steven Schveighoffer (schveiguy at yahoo.com)'s article
> On Thu, 09 Jun 2011 13:51:31 -0400, KennyTM~ <kennytm at gmail.com> wrote:
> > Given that the 'new' expression can be used in 'pure', should it be that
> > GC allocation functions like GC.malloc, GC.qalloc and GC.extend (?) be
> > weakly pure also?

> Yes.  But one of the possible issues here: weak purity is determined by
> the type of the parameters.  GC.malloc only takes non-reference types, so
> marking it as pure might make the compiler actually think these are
> strong-pure.

Would adding a third, dummy, reference-type parameter that takes a suitable default value allow you to hack
around this?

Cheers,
Pillsy


More information about the Digitalmars-d mailing list