[Q] type promotion in * and +

Didier Verna <[email protected]> Fri, 07 Apr 2006 14:53:46 +0200
Newsgroups gmane.lisp.allegro
Message-ID <[email protected]>
        Hi again,

if I compile these two functions below:

(defun my+ (a b)
  (declare (:explain :boxing :calls :types))
  (declare (type fixnum a))
  (declare (type fixnum b))
  (+ a b))

(defun my* (a b)
  (declare (:explain :boxing :calls :types))
  (declare (type fixnum a))
  (declare (type fixnum b))
  (* a b))

... and read the log file, I see that (+ FIXNUM FIXNUM) is considered to be a
FIXNUM, but that is not the case for * which returns a bigger integer.

I fail to understand why the addition doesn't return something bigger than a
fixnum, just like the multiplication. Actually, calling:

(my+ most-positive-fixnum most-positive-fixnum)

returns -2.


Thanks !

--
Didier Verna, [email protected], http://www.lrde.epita.fr/~didier

EPITA / LRDE, 14-16 rue Voltaire   Tel.+33 (1) 44 08 01 85
94276 Le Kremlin-BicĂȘtre, France   Fax.+33 (1) 53 14 59 22   [email protected]