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

Gaussian rationals



Not being a mathematician -- in fact, the only things I really believe
in are the integers from 0 through 1023, unless I have my shoes off
-- I feel that I'm way out of my depth here.  I was one of the people
who didn't want complexes to be required at all, because I can't figure
out who around here is going to implement them.  But whenever we do get
this installed, I would have no objection to Bawden's suggestion that we
do the mathematically right thing here.  Anyone who is depending on
getting an error in some situation isn't writing portable Common Lisp
anyway, and if the user is expecting an error on (SQRT -1) and instead
gets #C(0 1), I see no problem there.  The one problem I do see is that
we don't want users to take (SQRT 4.0) and get a complex, so we need a
rule that says that if you put a real in, floating or not, you get one
out if possible.  But if the user who gets back a complex can simply say
to himself "Oh, that's an error if you're confined to the reals, but
here is what it looks like otherwise", then I've got no problem.  If we
ever start distributing Common Lisp to grade schools we may want to put
in ways to turn off complexes (or even fractions), but that's a
special-purpose hack.

While we're talking about canonical forms, I would like to propose once
again that we require both halves of a complex to be of the same type:
rationals or one of the flavors of float.  You would do the appropriate
floating-point contagion when the complex is created, not every time you
want to use it.  I may be revealing my naivete here, but this just looks
like the right thing to do, pure and simple.  It would clean up the
notation and make life easier for implementations that want to put in
special complex-number microcode or arrays for various complex types.  I
know that this was discussed before, but I don't remember any resolution
of the problem -- it just sort of faded away.  Is there really any
coherent argument for keeping things like #C(2/3 3.33e-1) around?  If
nobody talks me out of this in the next few hours, I am tempted to put
this on a ballot.

-- Scott