David Green wrote:
 On 2/23/06, Jonathan Lang wrote:
  (Another possibility would be to return a list of every possible
result when in list context, with the result that you'd get in scalar
context being element zero of the list.  This even has its uses wrt
sqrt(Num), providing a two-element list of the positive and negative
roots, in that order.  This option would apply to sqrt, exp, log, and
the trig functions.)

I was thinking functions like sqrt would return a disjunction... I suppose it's probably still most useful to return a single scalar by default, so there would be some pragma via which you could choose to get lists or to get junctions when there's more than one possible result.

(Perhaps if you <use Complex>, the default might be to return junctions or lists on the grounds that you're trying to be more mathematical?)

For the complex trig functions the result set is infinite with no obvious order to return the list in even lazily that provides anything useful. The results are all of the form A + (B + 2*pi*N)i where N can be any integer. It is worth much more effort to just return a consistent principle value and getting the branch cuts and the handling of signed zero correct then to worry about trying to return multiple values in these cases. For a through discussion see either the Ada or Common Lisp reference manuals.

Mark Biggar


Reply via email to