[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Side effecting constants inside functions
- To: evan@SU-CSLI.ARPA, Masinter.pa@XEROX.ARPA
- Subject: Re: Side effecting constants inside functions
- From: Daniel L. Weinreb <DLW@SCRC-QUABBIN.ARPA>
- Date: Tue, 3 Sep 85 13:22 EDT
- Cc: TIM@MIT-MC.ARPA, common-lisp@SU-AI.ARPA
- Fonts: CPTFONT, CPTFONTB, CPTFONTI
- In-reply-to: The message of 3 Sep 85 01:01-EDT from Evan Kirshenbaum <evan@SU-CSLI.ARPA>
Date: Mon 2 Sep 85 22:01:34-PDT
From: Evan Kirshenbaum <evan@SU-CSLI.ARPA>
(defmacro compute-once (form)
(let ((var (gensym)))
`(if (boundp ',var)
(setf ,var ,form))))
This lacks the self-modifying-ness of the original example.
And it doesn't work, if you run it interpreted and the interpreter
handles macros in the straightforward way (no automatic memoization,
etc). A new symbol is created each time by the call to gensym.
I believe that the claim in CLtL that the interpreter and the compiler
have precisely the same semantics "so far as possible" must be read with
the understanding that the semantics can differ in the face of macros
whose expansion causes side-effects.