guile-devel
[Top][All Lists]
Advanced

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

Re: Proposal: deprecate low-level numeric predicates


From: Andy Wingo
Subject: Re: Proposal: deprecate low-level numeric predicates
Date: Wed, 09 Mar 2011 22:59:07 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

On Tue 01 Mar 2011 20:20, Mark H Weaver <address@hidden> writes:

> Daniel Llorens <address@hidden> writes:
>> I tried to look into SCM_VALIDATE_REAL per the comment, I didn't get
>> far.
>
> Yes, SCM_VALIDATE_REAL (defined in validate.h) requires that the tested
> value be an inexact real, i.e. floating-point.  It will reject exact
> integers or exact rationals.  It really ought to be deprecated in
> master, and replaced with a new validator that uses scm_is_real.

Indeed.  Its only mention in Guile is

  bytevectors.c:1667:/* FIXME: SCM_VALIDATE_REAL rejects integers, etc. grrr */

I think it's OK to deprecate in stable-2.0, actually, using the same
mechanism as SCM_VALIDATE_INUM.

> SCM_REALP and SCM_COMPLEXP should also be deprecated.  It is very
> confusing that these macros do not correspond to `real?' and `complex?'.
> They should be replaced with renamed versions to reflect the fact that
> they are testing for particular low-level numeric representations.
> Maybe SCM_DOUBLE_P and SCM_COMPLEX_DOUBLE_P.

Sounds good to me too.

> SCM_NUMBERP, SCM_NUMP, and SCM_INEXACTP ought to be deprecated, and
> replaced with internal versions.

OK, but in master only please.

>  They check only for representations
> supported by the core implementation, and do not properly support GOOPS
> numeric classes (part of an upcoming patch series I'm working on).

I'm a little concerned about the impact goops numbers would have on
making type dispatch slower, like

    (cond
      ((symbol? x) ...)
      ((number? x) ...))

How many different kinds of numbers are we talking about?  Would be nice
to avoid having number? call a generic function.  Dunno.

> SCM_VALIDATE_NUMBER ought to be changed to use scm_is_number

Sure.  Anyone who really cares about speed will check for particular
number types.  In master only please, though, at least for now.

Andy
-- 
http://wingolog.org/



reply via email to

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