Is this function pure?

Janice Caron caron800 at googlemail.com
Tue Sep 18 12:35:04 PDT 2007


On 9/18/07, 0ffh <spam at frankhirsch.net> wrote:
> Therefore: In case of errors, there's an exception!
> (And, in this case, a double entendre. :-)

I don't think it's that simple. Exceptions should be allowed as flow
control structures even in pure code, and don't necessarily represent
an error. For example, a (pure) divide function might legitimately
throw a divide-by-zero exception, and then a (also pure) fixed-point
saturating divide function might legitimately call the first divide
function, catch the exception, and return the saturation value. None
of that violates purity.

I don't think you can ban try/catch in pure code, nor assume that
exception==error.

Of course, only Walter can tell us the /real/ (as in,
will-be-implemented) answer!



More information about the Digitalmars-d mailing list