Is this function pure?

0ffh spam at frankhirsch.net
Tue Sep 18 12:33:26 PDT 2007


Ingo Oeser wrote:
> Janice Caron wrote:
> 
>> OK, so change it to
>>
>> char[] probablyNotPure(int x)
>> [...]
>> I think it looks less easy to optimise now.
> 
> Ok, now that's impure, since now you are using the memory by returning it.
> This is really not side effect free. You are draining a global resource,
> which is a no-no for pure functions. All the discussions and points
> raised by the other people now apply.

I am afraid I must disagree.
We're talking functional purity in a programming context, not maths.
It is perfectly allowable in a purely functional language to return
a pointer to a heap allocated data structure.

Regards, frank



More information about the Digitalmars-d mailing list