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

macroexpansion environments



    Date: Mon 4 Jun 84 10:47:30-EDT
    From: "Walter van Roggen" <WVANROGGEN@DEC-MARLBORO.ARPA>

    Here's an interesting problem with Common Lisp:

    (defvar x 1)
    (defmacro m ()
      (print x)
      `(list ,x x))
    (let ((x 2)) (m))     ;case A
    (let ((x 2)) () (m))  ;case B

    In case A it will print a 1 and return the list (1 2).
    In case B it will print a 2 and return the list (2 2).

Think about what will happen when you compile this code.  Both cases will
print a 1 AT COMPILE TIME and include the list (1 2) in the expanded code.
Or, if you don't put an eval-when compile around the defvar of x, it will
blow out at compile time.

I don't think this is a very interesting problem: you have simply
constructed a program whose semantics cannot possibly be well-defined.