Is this function pure?

Steven Schveighoffer schveiguy at yahoo.com
Tue Sep 18 11:21:28 PDT 2007


"Steven Schveighoffer" wrote
> "Nathan Reed" wrote
>> It would be interesting to see if it's possible to write a function that 
>> acheives nondeterminism *without* either memory allocation or reading 
>> global state (e.g. rand()). I believe it's not.
>
> I don't follow... Isn't this a pure function?  no global state read/memory 
> allocation:
>
> int add(int x, int y)
> {
>   return x + y;
> }

Totally misread your challenge.  I thought you said impossible to write a 
function that achieves *determinism*.  Sorry :)

I think you are right.  I think the challenge can be reduced to just reading 
global state, as allocating memory is a subset of that.

-Steve 





More information about the Digitalmars-d mailing list