Is this function pure?
Nathan Reed
nathaniel.reed at gmail.com
Tue Sep 18 12:41:26 PDT 2007
Steven Schveighoffer wrote:
> Since y and z are pure, they should be able to run simultaneously on two
> cores. What happens when they both try to allocate memory?
The allocator has to deal with allocation requests coming from multiple
threads/cores anyway. This case presents no additional problem.
> I think exception catching should be outlawed in pure functions. This makes
> the pure function deterministic iff it does not throw an exception. You can
> handle cases like divide by zero just by checking if the divisor is 0.
Exception throwing and catching is deterministic too as long as the
condition that generates the exception is (which dividing by zero would
be). I think it is perfectly reasonable to allow pure functions to
throw and catch exceptions.
More information about the Digitalmars-d
mailing list