[pro] substitution macro lisp extension?

Nikodemus Siivola nikodemus at random-state.net
Wed Sep 22 16:23:05 UTC 2010


On 22 September 2010 19:16, Peter Seibel <peter at gigamonkeys.com> wrote:
> Can someone show an example of this defsubst in use? I'm not sure I
> understand what it's for.

To the best of my understanding it has two effects:

1. it allows reliable inlining on compilers that do not respect inline
declarations.

2. it allows the expansion to utilize the lexical context of the call site.

Consider:

(defmacro foo () :global)

(declaim (inline bar1))
(defun bar1 () (foo))

(defsubst bar2 () (foo))

(macrolet ((foo () :local))
  (values (bar1) (bar2)))  => :GLOBAL, :LOCAL

Cheers,

 -- Nikodemus




More information about the pro mailing list