[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Local redefs of special forms
Date: Wed, 11 Nov 87 16:28:54 PST
From: Jeff Barnett <jbarnett@nrtc.northrop.com>
If you allow FLETS, et al, to shadow special forms, there is an implementation
issue with inline function expansions nee DEFSUBSTs. The compiler cannot
substitute the function body and optimize as some compilers now do. In fact
the body must be (re)expanded in the null lexical environment no matter what.
Consider the following example:
(defsubst foo (x) (car x))
(flet((car (l) (cdr l)))
(foo (car q)))
While what you are saying is true, this particular case is not germaine
to the discussion, because CAR is not a special form, it is a function.
Also, if a compiler is going to do inline substitution, it should take
care to use the appropriate environment. I tried the above on a
Symbolics lispm and it simply decided not to do the inline substitution;
not optimal, but within the standard.
The problem you are describing DOES exist, but it is with macros. In
the case of inline functions, the compiler can simply punt using the
expansion if there is a name clash or use the global definition, but it
doesn't have the choice with macros. If you change the above example to
(defmacro foo (x)
`(car ,x))
you will encounter the problem. This problem that macros violate
lexical scoping is well-known, and there is ongoing research on how to
deal with it. A proposed solution was the subject of a presentation at
the 1986 Lisp & Functional Programming conference, with a title
something like "Hygienic Macro Expansion". There is a subcommittee of
X3J13 following the research, and if any acceptable solutions come up
I'm sure they will let us know about them.
barmar