[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Side effecting constants inside functions
- To: Masinter.pa@XEROX.ARPA
- Subject: Re: Side effecting constants inside functions
- From: Evan Kirshenbaum <evan@SU-CSLI.ARPA>
- Date: Mon 2 Sep 85 22:01:34-PDT
- Cc: TIM@MIT-MC.ARPA, common-lisp@SU-AI.ARPA, evan@SU-CSLI.ARPA
- In-reply-to: Message from "Masinter.pa@Xerox.ARPA" of Mon 2 Sep 85 17:53:00-PDT
>(defmacro compute-once (form)
> `(let ((value '(,nil . ,nil)))
> (cond ((car value) (cdr value))
> (t (setf (car value) t)
> (setf (cdr value) ,form))))
But wouldn't it be more reasonable to do something more like:
(defmacro compute-once (form)
(let ((var (gensym)))
`(if (boundp ',var)
,var
(setf ,var ,form))))
This lacks the self-modifying-ness of the original example.
-------