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

commonlisp types

    Date: Thu, 22 Dec 88 15:17 EST
    From: Kent M Pitman <KMP@STONY-BROOK.SCRC.Symbolics.COM>
    Fyi, it turns out this rationale doesn't hold as much water as you'd think.

     (defun bar (x) (symbolp x))

     (defun foo (x)
       (flet ((bar (y) (integerp y)))
	 (typep x '(satisfies bar))))

     (foo 'x)

    The correct answer is T, but I bet a lot of implementations return NIL
    in compiled code.

Like the Symbolics system, Boo, Hiss!

In terms of source transformations, this would have to compile the TYPEP
as follows:

(defun foo (x)
  (flet ((bar (y) (integerp y)))
    (let ((#:G0002 x))
      (macrolet ((bar (a) `(funcall (symbol-function 'bar) ,a)))
        (bar #:G0002)))))

Which is obviously going to require either a codewalker or a typewalker
to identify either locally defined functions or functions used in the
type expansion to shadow with MACROLET.

So I'm curious.  Does any compiler actually get this right?  Really,
this is a general problem with any form of source-code rewrites.  The
Symbolics compiler does get this right with inlined functions, but I'll
bet it doesn't with some other internal in-lined things that work as
source transformations.