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

Why does my Macro get expanded 8 times?



   Date: Tue, 12 Jul 88 16:57 EDT
   From: David L. Andre <DLA@JASPER.SCRC.Symbolics.COM>

       Date: Mon, 11 Jul 88 22:33:39 PDT
       From: gyro@kestrel.ARPA (Scott B. Layson)

       SCRC folks: surely one of the ways you considered fixing the problem
       was to make all macros displace in Phase I.  Why doesn't this work?

   Because the expansion of a macro depends on the environment in which the
   macro is expaneded.  If you trace the macroexpansions, you'll find that
   the expansions of the same form are (almost always) in different
   environments.

This makes no sense to me.  (See my previous message on the subject.)
The only property of an environment that can be relevant to a macro
expansion are the enclosing MACROLETs it records.  These had better be
the same every one of those eight times that poor user was complaining
his macro form was getting expanded!

I mean really, think about what you're saying.  CLtL makes no
reference to a single macro form getting multiply expanded in
different environments during a single compilation, and so correct
code cannot possibly depend on whatever it is your compiler is doing.

Seems to me it can be argued from first principles -- that is, from
CLtL, with no reference to the structure of your particular compiler
-- that the revised displacing technique I proposed in my previous
message (rplaca'ing the cons that points to the the macro form, rather
than the cons which is the head of the macro form) *must* work.

-- Scott