From: Gerald W. L. <Ger...@co...> - 2005-10-04 12:34:29
|
Arjen Markus wrote: >Hello all, > >I was just checking the various bug reports that are assigned to me >and I came across one (bug 1151935) that made me think: > >In general what should happen if a mathematical function is to be >evaluated for a set of argument for which it is not defined? > >In this case, the bug is that there is a division by zero and >this is reported as such, rather than as a clearer message >that the coefficient of variation is not defined if the mean >of the data is zero. > >My question: >- Should the function return such a (clearer) message or >- Should it return an empty string (not an error) thereby > leaving it to the caller to handle the _undefined_ > situation > >I can argue either way, but we should probably try for a >consistent practice. > > IMHO, I would emulate what sqrt() does in expr, namely: % expr {sqrt(-1.0)} domain error: argument not in valid range % set errorCode ARITH DOMAIN {domain error: argument not in valid range} % set errorInfo domain error: argument not in valid range while executing "expr {sqrt(-1.0)}" In other words, raise an error -- but be sure to set error code to some appropriate list of informational elements. Sincerly, Gerald W. Lester |