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

SUBST vs INLINE, consistent compilation



I think there is some rationale both for SUBST-type macros and for INLINE.

SUBST macros are quite important for cases where the semantics of
lambda-binding is not wanted, e.g., where (use your favorite syntax):

(DEFSUBST SWAP (X Y)
    (SETQ Y (PROG1 X (SETQ X Y]

This isn't a real example, but the idea is that sometimes a simple substitution
expresses what you want to do more elegantly than the equivalent

(DEFMACRO SWAP X
	\(SETQ ,(CADDR X) (PROG1 ,(CADR X) (SETQ ,(CADR X) ,(CADDR X]

These are definitely not doable with inlines. (I am not entirely sure they can be
correctly implemented with SUBST-macros either.)

-----------------

There is a more important issue which is being skirted in these various
discussions, and that is the one of consistent compilation: when is it
necessary to recompile a function in order to preserve the equivalence of
semantics of compiled and interpreted code. There are some simple situations
where it is clear:
	The source for the function changed
	The source for some macros used by the function changed

There are other situations where it is not at all clear:
	The function used a macro which accessed a data structure which
	has changed.

Tracing the actual data structures used by a macro is quite difficult. It is not
at all difficult for subst and inline macros, though, because the expansion of
the macro depends only on the macro-body and the body of the macro
invocation.

I think the important issue for Common Lisp is: what is the policy on consistent
compilation?

Larry