Tassilo Horn <t...@gnu.org> writes: > Phillip Lord <phillip.l...@newcastle.ac.uk> writes: > >> Is it because you're expansion returns the symbol and not the >> function. >> >> ('inc 2) >> >> returns nil which is what I think is happening. > > Ah, indeed. I really whished that would throw an error. I mean, it's > cool that keywords can lookup themselves in maps, but I don't think > that's needed for symbols. At least I've never seen occurences of > > ('foo my-map) > ('foo my-map ::default) > > in real code, and it's likely to shadow errors such as mine.
I'd agree. I have to admit I didn't know symbols implemented IFn -- in fact, I looked up the code to make sure. I think that ('foo my-map) looks fairly pathological and (get my-map 'foo) seems more likely. Although, of course, you might do something like (def x {'symb 1}) (def foo (let [x] (fn[y](y x)))) (foo 'symb) But still a crash seems more sensible to me. I'd be interested if anyone can show a sensible use for this. > Anyway, using `resolve` works: > > (defmacro do-do [x afn] > `(do ~((resolve afn) x))) > > Is that what one would use, or is there something better? My solution involved "eval"; I think yours is better. Phil -- -- 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/groups/opt_out.