Re: Macro problems with delay
On 10 Sep 2010, at 03:11, joshua-choi wrote: And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 If I understand the comment (the following form is the culprit...) correctly, it's not the macroexpansion that fails, but the evaluation of the resulting expression. Is that correct? In that case, it's not really a macro problem, but a problem with a complex use case of alter- var-root. Konrad. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Macro problems with delay
That ought to be correct, but I can't reconcile that with the error message. Doesn't the Can't embed object in code, maybe print-dup not defined error only appear in macros, when some object being spliced into a macro's expansion is not a basic Clojure form? Yet, you are correct, commenting out that function call in the macro does prevent the error. I don't understand it. Konrad Hinsen wrote: On 10 Sep 2010, at 03:11, joshua-choi wrote: And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 If I understand the comment (the following form is the culprit...) correctly, it's not the macroexpansion that fails, but the evaluation of the resulting expression. Is that correct? In that case, it's not really a macro problem, but a problem with a complex use case of alter- var-root. Konrad. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Macro problems with delay
You're right about the namespace-qualification: I accidentally macroexpanded with syntax-quote rather than quote. My mistake; the actual expansion is the same, but without namespace-qualification. Using (var ~fn-name) results in the same error, unfortunately. I think now the attempted embedding of a delay into macro code is somewhere else, but I don't know. Meikel Brandmeyer wrote: Hi, On 10 Sep., 03:11, joshua-choi rbysam...@gmail.com wrote: I am running into a problem sometimes when I call a certain macro I defined. This problem macro (and an associated problem function) is: http://gist.github.com/572875 I run into this error (which is at a call to the macro, but *not* at the *first* time it's called for some reason!): http://gist.github.com/572824 And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 I *cannot* figure this out. The error seems to be that there's a delay directly being embedded in some macro's form, but the delay call in the function that's causing the problem…is in a function! How can the delay show up at hound.clj's compile time? I must confess, I'm not sure, what's going on. However the expansion looks suspicious. Everything is namespace qualified. One thing core does differently to your approach is using the var special form. You might try: (defmacro general-defmaker [def-form description rule-type-kw fn-name forms] `(do (~def-form ~fn-name ~...@forms) (alter-var-root (var ~fn-name) named-rule-maker ~rule-type-kw) (var ~fn-name))) But this is just guessing. As I said above: everything is qualified. So maybe the problem is at some surrounding macro or so. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Macro problems with delay
I've solved the problem. I found that it only occurred when general- defmaker was called with its forms argument containing another general- defmaker call with def-form being defmacro. Thus, in the inner general- defmaker call, the *result* of (NamedRule. (delay …)) was embedded into a defmacro call, resulting in the error. The solution was to change (alter-var-root maker-var# named-rule-maker ~rule-type-kw) to (when (= '~def-form `defmacro) (alter-var-root maker-var# named-rule-maker ~rule-type-kw)) Thanks, everyone for your help. joshua-choi wrote: That ought to be correct, but I can't reconcile that with the error message. Doesn't the Can't embed object in code, maybe print-dup not defined error only appear in macros, when some object being spliced into a macro's expansion is not a basic Clojure form? Yet, you are correct, commenting out that function call in the macro does prevent the error. I don't understand it. Konrad Hinsen wrote: On 10 Sep 2010, at 03:11, joshua-choi wrote: And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 If I understand the comment (the following form is the culprit...) correctly, it's not the macroexpansion that fails, but the evaluation of the resulting expression. Is that correct? In that case, it's not really a macro problem, but a problem with a complex use case of alter- var-root. Konrad. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Macro problems with delay
This still doesn't quite add up to me. What's the consequence of not alter-var-root'ing maker-var# if def-form is a defmacro? Why would def-form be a defmacro in the first place? Also, I don't think you've given the example of the actual call that gave the error, only the macroexpansion of it. Can you provide that as well? thanks, Cyrus On Sep 10, 2010, at 10:30 AM, joshua-choi wrote: I've solved the problem. I found that it only occurred when general- defmaker was called with its forms argument containing another general- defmaker call with def-form being defmacro. Thus, in the inner general- defmaker call, the *result* of (NamedRule. (delay …)) was embedded into a defmacro call, resulting in the error. The solution was to change (alter-var-root maker-var# named-rule-maker ~rule-type-kw) to (when (= '~def-form `defmacro) (alter-var-root maker-var# named-rule-maker ~rule-type-kw)) Thanks, everyone for your help. joshua-choi wrote: That ought to be correct, but I can't reconcile that with the error message. Doesn't the Can't embed object in code, maybe print-dup not defined error only appear in macros, when some object being spliced into a macro's expansion is not a basic Clojure form? Yet, you are correct, commenting out that function call in the macro does prevent the error. I don't understand it. Konrad Hinsen wrote: On 10 Sep 2010, at 03:11, joshua-choi wrote: And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 If I understand the comment (the following form is the culprit...) correctly, it's not the macroexpansion that fails, but the evaluation of the resulting expression. Is that correct? In that case, it's not really a macro problem, but a problem with a complex use case of alter- var-root. Konrad. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Macro problems with delay
I am running into a problem sometimes when I call a certain macro I defined. This problem macro (and an associated problem function) is: http://gist.github.com/572875 I run into this error (which is at a call to the macro, but *not* at the *first* time it's called for some reason!): http://gist.github.com/572824 And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 I *cannot* figure this out. The error seems to be that there's a delay directly being embedded in some macro's form, but the delay call in the function that's causing the problem…is in a function! How can the delay show up at hound.clj's compile time? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Macro problems with delay
Hi, On 10 Sep., 03:11, joshua-choi rbysam...@gmail.com wrote: I am running into a problem sometimes when I call a certain macro I defined. This problem macro (and an associated problem function) is: http://gist.github.com/572875 I run into this error (which is at a call to the macro, but *not* at the *first* time it's called for some reason!): http://gist.github.com/572824 And here is a full macro-expansion of the call at which the error happens: http://gist.github.com/572879 I *cannot* figure this out. The error seems to be that there's a delay directly being embedded in some macro's form, but the delay call in the function that's causing the problem…is in a function! How can the delay show up at hound.clj's compile time? I must confess, I'm not sure, what's going on. However the expansion looks suspicious. Everything is namespace qualified. One thing core does differently to your approach is using the var special form. You might try: (defmacro general-defmaker [def-form description rule-type-kw fn-name forms] `(do (~def-form ~fn-name ~...@forms) (alter-var-root (var ~fn-name) named-rule-maker ~rule-type-kw) (var ~fn-name))) But this is just guessing. As I said above: everything is qualified. So maybe the problem is at some surrounding macro or so. Sincerely Meikel -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en