Re: Macros, namespaces, and lexical scope

2009-09-26 Thread Meikel Brandmeyer
Hi, Am 26.09.2009 um 17:06 schrieb Constantine Vetoshev: This seems indeed useless at a first glance, but looking down the cause trace usually shows the real problem. Full stack trace follows, although I still don't know what it means. No message. [Thrown class

Re: Macros, namespaces, and lexical scope

2009-09-26 Thread Meikel Brandmeyer
Hi, Am 25.09.2009 um 22:49 schrieb Constantine Vetoshev: (defmacro def-with-db-macro [macro-name open-fn close-fn] `(defmacro ~macro-name [[var# open-args#] body#] `(let [~var# (apply ~'~open-fn [...@open-args#])] (try ~...@body# (finally (~'~close-fn ~var#))

Re: Macros, namespaces, and lexical scope

2009-09-26 Thread Constantine Vetoshev
On Sep 26, 7:35 am, Meikel Brandmeyer m...@kotka.de wrote: The problem is, that you quote the symbol you inject into the inner defmacro. Hence it does not get resolved. The solution in this case seems to be to syntax-quote the symbol correctly before injection. Replace the two ~'~ with ~~ and

Re: Macros, namespaces, and lexical scope

2009-09-26 Thread Chouser
On Fri, Sep 25, 2009 at 4:49 PM, Constantine Vetoshev gepar...@gmail.com wrote: Chris Houser has summarized the problem here more succinctly than I can: http://paste.lisp.org/display/87734 This is a syntax-quote expansion-timing issue, which is why Meikel's solutions works. I think it would

Re: Macros, namespaces, and lexical scope

2009-09-25 Thread John Harrop
On Fri, Sep 25, 2009 at 4:49 PM, Constantine Vetoshev gepar...@gmail.comwrote: (let [f1 #(inc %)] (defmacro m1 [x] `(~f1 ~x))) (m1 12) = No message. [Thrown class java.lang.ExceptionInInitializerError] The equivalent works in Common Lisp (Allegro CL and SBCL): (let ((f1 (lambda

Re: Macros, namespaces, and lexical scope

2009-09-25 Thread Constantine Vetoshev
On Sep 25, 6:02 pm, John Harrop jharrop...@gmail.com wrote: I don't think you can use things like defmacro in a let. This works: (let [y 10] (defmacro m1 [] `(list ~y))) (m1) = (10) --~--~-~--~~~---~--~~ You received this message because you are

Re: Macros, namespaces, and lexical scope

2009-09-25 Thread John Harrop
On Fri, Sep 25, 2009 at 8:48 PM, Constantine Vetoshev gepar...@gmail.comwrote: On Sep 25, 6:02 pm, John Harrop jharrop...@gmail.com wrote: I don't think you can use things like defmacro in a let. This works: (let [y 10] (defmacro m1 [] `(list ~y))) (m1) = (10) Well, that's