[Top][All Lists]

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

overloading predicates

From: Marco Maggi
Subject: overloading predicates
Date: Tue, 13 Feb 2007 07:39:19 +0100


  some  time ago  I asked  if predicates  like  NUMBER?  and
INTEGER? must  return #t only when applied  to Guile's built
in  numbers, or  they  can be  overloaded  by extensions  to
return  #t when  applied to  other number-like  objects upon
which  it  is  possible  to  apply  all  the  common  number
operators, like +,  - and SIN. And I  think Neil J. answered
that:  yes,  only  built   in  Guile  numbers should be #t.

  I still have the idea that it is convenient that INTEGER?,
REAL? and COMPLEX? can  be applied to classes of number-like
objects; for example: I do not see why a user could not want
to test the realness of  a custom vector with REAL?, so that
functions like:

    (define (my-op a)
      (if (real? a)
          (some-thing a)
          (some-other-thing (real-part b))))

can be  used for  both built in  real numbers  and extension
added number like objects, like vectors and matrices.

  To  distinguish built  in reals  from other  "real" things
there  is  the  IS-A?  predicate,  and to  make  "old"  code
continue to work there are modules.

  So how bad it is to break this?

Marco Maggi

"They say jump!, you say how high?"
Rage Against the Machine - "Bullet in the Head"

reply via email to

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