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

INLINE declarations



    Date: Fri, 15 Sep 89 09:27 PDT
    From: Siskind.pa@xerox.com

    Does the L/G-machine CommonLisp compiler support
    INLINE declarations? The following examples seem
    to indicate no. If you compile them and then
    disassemble them you will see that the calls to
    map and bar are not inline expanded. I know that
    CLtL allows a compiler to ignore the INLINE
    declarations but I always thought that Symbolics
    supported them. Am I doing something wrong?
	    Jeff

    (defun FOO (x)
     (declare (inline map))
     (map 'list #'(lambda (y) (1+ y)) x))

    (defun BAR (x)
     (1+ x))

    (defun BAZ (x)
     (declare (inline map bar))
     (map 'list #'bar x))

    (defun QUUX (x)
     (declare (inline bar))
     (loop for y in x collect (bar y)))
    -------

You have to PROCLAIM a function INLINE prior to compiling it in order
for it to be open-coded, because the compiler has to know at the
time it is compiling the inline function that it should save enough
information for the expansion.

If you don't want the function open-coded by default, you can then
follow the definition with a NOTINLINE proclamation.  This clarification
will appear in the ANSI Common Lisp standard that we're working on.

So, the way to do your BAR example is to write

(proclaim '(inline bar))
(defun bar (x)
  (1+ x))
(proclaim '(notinline bar))

(defun quux (x)
  (declare (inline bar))
  (loop for y in x collect (bar y)))

In order to make MAP be open-codable, you have to PROCLAIM it INLINE,
then recompile the definition.  Note, by the way, that Symbolics already
open-codes the list-specific mapping primitives (MAPC, MAPCAR, etc.).
Therefore, the following is fully open-coded:

(defun BAZ (x)
  (declare (inline bar))
  (mapcar #'bar x))
                                                barmar