trusted purity?

Henning Pohl henning at still-hidden.de
Mon Apr 29 04:50:10 PDT 2013


On Monday, 29 April 2013 at 11:32:33 UTC, monarch_dodra wrote:
> I'm still worried about what it means for a pure function to 
> throw... (I'm thinking about the  "enforce(malloc)" scheme)

If malloc returns null, we are out of memory. In D this is not an 
exception, it is an error. So I guess we just need to check the 
pointer returned by malloc and throw an OutOfMemoryError on 
failure. Thus if the ctor called is nothrow, it can be marked as 
nothrow, too.

So in this case, there should be no problem making it pure.


More information about the Digitalmars-d mailing list