guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] First batch of numerics changes


From: Andy Wingo
Subject: Re: [PATCH] First batch of numerics changes
Date: Fri, 28 Jan 2011 13:19:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Mark,

On Thu 27 Jan 2011 23:06, Mark H Weaver <address@hidden> writes:

> I'm having second thoughts about two of the patches:
>
> * Patch 0010: `inf?' and `nan?' throw exceptions when applied to
>   non-numbers
>
> Previously, these predicates would return #f in that case.  I tend to
> prefer strictness, but perhaps backward compatibility is more important
> than strictness here.  What do you think?

I think that certainly when it comes to numbers, strictness is good.  In
particular the r6rs says:

    (zero? z)     procedure
    (positive? x) procedure
    (negative? x) procedure
    (odd? n)      procedure
    (even? n)     procedure
    (finite? x)   procedure
    (infinite? x) procedure
    (nan? x)      procedure

The name of the argument indicates the type, as noted earlier in the
report.  `z' is a complex number, `x' is a real, and `n' is an integer.
It is an error to pass a non-integer to even?.  It is also an error to
pass a non-real to infinite?.

(Note that the domain of first 5 predicates is specified in R5RS as
well.)

Given that the R5RS does not discuss infinities, and they were only
added in Guile 1.8 (I believe), I think we have some room for change.
We should change to the R6RS semantics, I think.

> I am leaning toward the following:
>
>   (* 0 +inf.0) ==> +nan.0
>   (* 0 +nan.0) ==> +nan.0
>   (* 0 1.0)    ==> 1.0

==> 0.0, you mean.

>   (* 0 0.0)    ==> 0.0
>
> What do you think?

I think your suggestion is a good one.  But I don't really know what I'm
talking about ;-)

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]