Should GC.malloc be considered 'pure'?

Robert Jacques sandford at jhu.edu
Sat Jun 11 12:16:01 PDT 2011


On Sat, 11 Jun 2011 14:59:55 -0400, pillsy <pillsbury at gmail.com> wrote:

> == 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

Given that malloc returns a mutable pointer, I think it would/should be  
considered weakly-pure.


More information about the Digitalmars-d mailing list