Re: rules for writing macros

2009-02-15 Thread Stuart Halloway
Does this clarify the point I was making? When writing macros, you cannot dynamically build one of the syntactic sugar forms. For example, you cannot write a macro that expands cls and member into (cls/member): (defmacro call-static [cls member] `(~cls/~member)) -

Re: rules for writing macros

2009-02-04 Thread Stuart Halloway
Thanks Mark, Chouser, I will update that section of the book with a corrected example in Beta 7. Cheers, Stuart On Tue, Feb 3, 2009 at 11:26 AM, Mark Volkmann r.mark.volkm...@gmail.com wrote: Now I remember what I was thinking about. This isn't so much a difference between macros and

Re: rules for writing macros

2009-02-04 Thread H Durer
Marde, Feb 3, 2009 at 14:24, Konrad Hinsen konrad.hin...@laposte.net skribis: [...] I can't think of anything that would be forbidden in a macro but allowed in a plain function. There are many things that don't make sense in a macro, of course: launching agents, opening windows, ... Well, for

Re: rules for writing macros

2009-02-04 Thread CuppoJava
Personally I find that the clearest way to think about macros, is to treat them like a *very* advanced search-and-replace feature. Just keep in mind that macros expand into code, and check to make sure that your generated code is indeed valid code.

Re: rules for writing macros

2009-02-04 Thread Nathanael Cunningham
I just wanted to point out that ' is syntactic sugar for (quote) not (list). (list) will evaluate your arguments, where as '() will not. So if you try to use them interchangeable you'll run into trouble. user (list 1 2 (+ 1 2)) (1 2 3) user '(1 2 (+ 1 2)) (1 2 (+ 1 2)) Its a pretty common lisp

Re: rules for writing macros

2009-02-03 Thread Konrad Hinsen
On Feb 3, 2009, at 14:49, Mark Volkmann wrote: I see from the feedback so far that my statements are wrong. However, I think it's true that there are *some* things you can do in a function that you cannot do in a macro, and perhaps vice-versa. Are those clearly documented anywhere? If not,

Re: rules for writing macros

2009-02-03 Thread GS
On Feb 4, 12:01 am, Mark Volkmann r.mark.volkm...@gmail.com wrote: Are the following statements true? They aren't discussed athttp://clojure.org/macros, but I think they are true. Macros cannot call other macros during their evaluation, but they can expand to code that calls macros. I

rules for writing macros

2009-02-03 Thread Mark Volkmann
Are the following statements true? They aren't discussed at http://clojure.org/macros, but I think they are true. Macros cannot call other macros during their evaluation, but they can expand to code that calls macros. Macros cannot use syntactic sugar such as '(items) to create a list and

Re: rules for writing macros

2009-02-03 Thread Mark Volkmann
On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: On Feb 3, 2009, at 14:49, Mark Volkmann wrote: I see from the feedback so far that my statements are wrong. However, I think it's true that there are *some* things you can do in a function that you cannot do in a

Re: rules for writing macros

2009-02-03 Thread Chouser
On Tue, Feb 3, 2009 at 11:26 AM, Mark Volkmann r.mark.volkm...@gmail.com wrote: Now I remember what I was thinking about. This isn't so much a difference between macros and functions as it is a rule about something you cannot do in a macro. Quoting from Programming Clojure ... You cannot

Re: rules for writing macros

2009-02-03 Thread Achim Passen
Hi! Am 03.02.2009 um 17:26 schrieb Mark Volkmann: On Tue, Feb 3, 2009 at 8:24 AM, Konrad Hinsen konrad.hin...@laposte.net wrote: On Feb 3, 2009, at 14:49, Mark Volkmann wrote: I see from the feedback so far that my statements are wrong. However, I think it's true that there are

Re: rules for writing macros

2009-02-03 Thread Daniel Jomphe
Mark Volkmann wrote: I see from the feedback so far that my statements are wrong. However, I think it's true that there are *some* things you can do in a function that you cannot do in a macro, and perhaps vice-versa. Are those clearly documented anywhere? If not, what are some? You might

Re: rules for writing macros

2009-02-03 Thread Konrad Hinsen
On Feb 3, 2009, at 14:01, Mark Volkmann wrote: Are the following statements true? They aren't discussed at http://clojure.org/macros, but I think they are true. Macros cannot call other macros during their evaluation, but they can expand to code that calls macros. Macros can certainly