This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: SCM_VALIDATE_...



I wonder if we're committing a confusion when we talk about
specializing GOOPS methods on realness, integerness, etc.

(real? N) is true if the imaginary component of N is exactly zero.  It
doesn't have anything to do with N's representation, or anything
traditionally considered part of N's "type".  It's only because we're
used to statically typed languages like C, who want to discover each
number's representation at compile-time, that we tend to find this
confusing.  But R5RS is very clear on the matter.

Trying to specialize a GOOPS method on "reals", in the sense of real?,
is like trying to specialize the method on prime numbers.  real? is a
computed property of the number, not its type.  Its type is "number".

Now, if we want to specialize on *representations*, that makes sense
to me.  I think it makes perfect sense to have a hierarchy of numeric
types, with <number> (or whatever) at the root, with subclasses
<fixnum>, <flonum>, <bignum>, and so on.

If we don't get this distinction right, it'll be difficult to add new
*representations* and have the value predicates, like real? and
integer?, work correctly on them.

I guess my point is this: it doesn't seem to me like the hierarchy of
representations and the hierarchy of number kinds (real?, integer?,
etc.) are necessarily identical.  Are they?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]