Is this function pure?
Nathan Reed
nathaniel.reed at gmail.com
Tue Sep 18 10:57:48 PDT 2007
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 just realized that (as someone else pointed out) taking the address of
a local variable would also be nondeterministic. Pointer shenanigans in
general can lead to nondeterminism, so maybe pointers should be
forbidden entirely in pure functions. Given that pointers are rarely
used in D except for interfacing with C functions and suchlike, this
seems like it would be not entirely unreasonable.
Thanks,
Nathan Reed
More information about the Digitalmars-d
mailing list