Should GC.malloc be considered 'pure'?

Robert Jacques sandford at jhu.edu
Thu Jun 9 18:23:39 PDT 2011


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? And should it apply to other managed allocators as  
> well, e.g. the proposed TempAlloc?
>
> I'm asking this as one of the specializations of std.conv.toImpl calls  
> GC.malloc, which is one of the 11 causes preventing std.conv.to from  
> being pure, and GC.qalloc and GC.extend (and memcpy and Array.capacity)  
> are used by std.array.appender (of pure range), and appender is also a  
> major reason why std.conv.to is not pure.

I think most of the GC functions should be usable in pure functions, but I  
don't know how we'd accomplish that from a technical perspective. Another  
thing to consider is whether GC.malloc should be valid during CTFE.


More information about the Digitalmars-d mailing list