Re: about macro exception : Unable to resolve classname: LinkedList, macro question and possible better approach
All your macro needs to do is to convert the first form into the second. thanks james, that make sense for me... I don't know what the rest of your function is supposed to be doing you can check my second example (def data (atom )) (defmacro blahhh [] (go (let [ch (chan)] (do (loop [] (let [res (! ch)] (if (= res secret) (do (println res) (reset! data res)) (recur) (do(doseq [word [blah bang secret goal]] (put! ch word)) It only waits a specific value in the channel and do somehting...in this case change an atom...I'm still curious about why I get that error when I declare it likes macro but it works when it's a function 3) I've this other code (defmacro defbus [bus-name args code] `(eb/on-message (str *ns* : ~bus-name) (fn ~args ~code))) basically I need convert from this (defbus some-bus [a] (eb/reply (str a))) to this (eb/on-message some-namespace:some-bus (fn [a](eb/reply (str a I did this (defmacro defbus [bus-name args code] `(eb/on-message (str *ns* : ~bus-name) (fn ~args ~code))) or (defmacro def-bus [bus-name args code] `(let [fun# (fn ~args ~code)] (eb/on-message (str *ns* ~bus-name) fun#))) the macro-expansion looks ok but when I try use it..I get some-bus is not defined..seems than it's trying evaluate the name..is it ok??..how can avoid it??... thanks again james -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: about macro exception : Unable to resolve classname: LinkedList, macro question and possible better approach
Sure, because you haven't quoted the symbol. If you write: (str *ns* : some-bus) ups!!, yes I forget quoted the symbol, thanks james!!... In Clojure, then Clojure will look for a variable called some-bus. The error you get is because it can't find such a variable. You want to either quote the symbol, or turn it into a string, e.g. (str *ns* : (quote ~bus-name)) ; or (str *ns* : ~(str bus-name)) - James just now I'm gonna use the defbus macro, I preferred use a function instead for the other case based in your suggestion and works really well (I changed the async code for a more readable too :D)... -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: about macro exception : Unable to resolve classname: LinkedList, macro question and possible better approach
On 8 March 2015 at 20:05, coco clasesparticulares...@gmail.com wrote: I don't know what the rest of your function is supposed to be doing you can check my second example I'm afraid that doesn't explain you intend your function to do. You appear to be setting up some form of message passing system, but you don't explain to what purpose you're doing this, or why you're going about doing it in such an unusual fashion. The reason I ask is that there may be a far better way of solving your problem. It only waits a specific value in the channel and do somehting...in this case change an atom...I'm still curious about why I get that error when I declare it likes macro but it works when it's a function It's probably because the return value from your macro was not valid Clojure code. I did this (defmacro defbus [bus-name args code] `(eb/on-message (str *ns* : ~bus-name) (fn ~args ~code))) the macro-expansion looks ok but when I try use it..I get some-bus is not defined..seems than it's trying evaluate the name..is it ok??..how can avoid it??... Sure, because you haven't quoted the symbol. If you write: (str *ns* : some-bus) In Clojure, then Clojure will look for a variable called some-bus. The error you get is because it can't find such a variable. You want to either quote the symbol, or turn it into a string, e.g. (str *ns* : (quote ~bus-name)) ; or (str *ns* : ~(str bus-name)) - James -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: about macro exception : Unable to resolve classname: LinkedList, macro question and possible better approach
You're not using macros correctly. A macro does not evaluate its arguments, but it does evaluate its return value. The only thing a macro should do is to transform one piece of code into another. So let's look at what you want your syntax to look like: (send! (function-blah hi!)) Now consider how it would have to look if you were using a function instead: (send!* 'function-blah hi!) Notice how we've quoted the function name and removed the surrounding list. All your macro needs to do is to convert the first form into the second. So you'd write something like: (defmacro send! [[func args]] `(send!* (quote ~func) ~@args)) Generally speaking, you should prefer functions over macros wherever possible. If you must have a macro, make it a slim wrapper around a function. I don't know what the rest of your function is supposed to be doing. The use of core.async and resolve is very odd. Could you elaborate on its purpose? - James On 7 March 2015 at 03:40, coco clasesparticulares...@gmail.com wrote: sorry for my crappy code, but I was changing some conditions and testing my parameters before and I end with this code (if (not (false? res)) res (recur)) I must write just (if res res (recur)) -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: about macro exception : Unable to resolve classname: LinkedList, macro question and possible better approach
sorry for my crappy code, but I was changing some conditions and testing my parameters before and I end with this code (if (not (false? res)) res (recur)) I must write just (if res res (recur)) -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.