Clojure vs. CL macros question

130 views
Skip to first unread message

Stuart Halloway

unread,
Dec 19, 2008, 2:05:47 PM12/19/08
to clo...@googlegroups.com
According to Paul Graham's On Lisp, macroexpanders should be purely
functional, and you should not count on how often a macro gets
expanded. This seems like a reasonable restriction for Clojure too.
However, Chouser posted an example that shows the expansion of proxy
does have a side effect [2].

Should macros written by ordinary mortals follow PG's rule? If not,
should this be listed as a difference from other Lisps at [3]?

Stuart

[1] http://www.paulgraham.com/onlisp.html. Free download, see
discussion in 10.3.
[2] http://paste.lisp.org/display/72406
[3] http://clojure.org/lisps

Stuart Sierra

unread,
Dec 19, 2008, 2:14:16 PM12/19/08
to Clojure
I think it's a generally good idea for macros to be purely functional,
but it's not always a requirement. As long as Clojure remains
exclusively a compiler and not an interpreter (unlike some CL
implementations) I think it is safe to assume that macros will only
run at compile time.
-S

Mon Key

unread,
Dec 19, 2008, 11:36:27 PM12/19/08
to Clojure
> This seems like a reasonable restriction for Clojure too.

Third rule. Macros break the rules. Don't place arbitrary
restrictions on rule breaking :P

s_P
On Dec 19, 2:05 pm, Stuart Halloway <stuart.hallo...@gmail.com> wrote:

Rich Hickey

unread,
Dec 21, 2008, 10:06:40 AM12/21/08
to Clojure


On Dec 19, 2:05 pm, Stuart Halloway <stuart.hallo...@gmail.com> wrote:
> According to Paul Graham's On Lisp, macroexpanders should be purely
> functional, and you should not count on how often a macro gets
> expanded. This seems like a reasonable restriction for Clojure too.
> However, Chouser posted an example that shows the expansion of proxy
> does have a side effect [2].
>
> Should macros written by ordinary mortals follow PG's rule?

Yes.

> If not,
> should this be listed as a difference from other Lisps at [3]?
>

No. There's no significant difference between CL and Clojure in this
area.

No one should come to rely on the implementation details of proxy or
gen-class.

Rich
Reply all
Reply to author
Forward
0 new messages