On Tue, Jul 05, 2005 at 09:49:33PM +0100, Tom Anderson wrote:
> Are there any uses for NaN that aren't met by exceptions?

Sure.  If you can naturally calculate two things at once, but one might
turn out to be a NaN under current rules.

    x, y = calculate_two_things()
    if isnan(x):
        perform_next_step_with_only_y(y)
    else:
        perform_next_step_with_both(x, y)

Under your scheme, you'd have to write
    try:
        x, y = calculate_two_things()
    except NaNException:
        y = calculate_one_thing()
        perform_next_step_with_only_y(y)
    else:
        perform_next_step_with_both(x, y)
and at the very least duplicate the code for calculating 'y', possibly
re-doing a lot of work at runtime too.

Jeff

Attachment: pgpVUpJh4xufX.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to