[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: arithmetic issues
> From: William D Clinger <will@xxxxxxxxxxx>
> ((<float> +) 1.1 'a)
> = (+ (<float> 1.1) (<float> '#(2.2)))
> = (+ 1.1 ?????)
> In terms of elegance, it seems sorta random to me for <float>
> to be the identity on flonums, to coerce other numeric types
> to flonums, to coerce procedures to procedures that map <float>
> across their arguments, and to be an error on things that are
> neither numbers nor procedures.
although somewhat off topic
- personally I like the idea of the scheme environment defining
a few basic <environment-exception> global variables, which
function implementations may use to determine what they should
do when detecting an unexpected condition.
such as possibly: <throw-invalid-operand-exception> :: [#t or #f]
if #t an <invalid-operand-exception> is thrown upon such an error,
or otherwise some default value is returned, which may include a
<void> return value if no other value is considered reasonable.
thereby an evaluation error need not halt execution, but
allow the result of an otherwise erroneous evaluation to be
propagated, thereby potentially caught and replaced with an
alternate default value if, when, and where desired in the
program; and/or alternatively exceptions may be caught at some
outer level of evaluation, and return an alterative value at
that point, or further throw an exception, ultimately propagating
to the top-level environment if otherwise uncaught.