Hello,

I'm playing around with compiler macros with the ultimate goal to
improve generic function performance by using a fixed expansion for
known types of arguments.  This expansion should only be used when
types are really known (otherwise the generic function should be
called), thus I'm missing badly the function variable-information
which did not make it into ANSI CL.

Now, I've sort of figured out how to get at the CMUCL type information of
some local variable, namely:

(defun test (x) (* x x))
(define-compiler-macro test (x &environment env)
  (format t "**** The environment is:")
  (describe env)
  (format t "~%**** The variable type is:")
  (princ (c::leaf-type (cdr (assoc x (c::lexenv-variables env)))))
  `(test x))

Unfortunately, this works only when I compile

(let ((x 2.0d0))
  (declare (type double-float x))
  (test x))

with the declaration which should be unnecessary when I read the
documentation correctly.  Why is that?

Furthermore, I'm surely not the first working in this direction,
therefore I would appreciate any remarks.  It seems to me to be a very
promising thing which one could extend even to simulate something like
Dylan's sealing.

Yours, Nicolas.

Reply via email to