Hey, thanks for the deep dive, but I'm not sure I either understand, or that it is correct.
So what we end up with is the equivalent to analyzing the expression `(. > clojure.lang.Numbers (add 10 100))`. > When I run my example, I get: ClassCastException clojure.lang.Symbol cannot be cast to java.lang.Number clojure.lang.Numbers.add When I macroexpand-1 my example, I also get the same ClassCastException. But if we follow your step by step, you make it sound like it would work and return 110. So at which step would this exception be thrown? And why? On Thursday, 15 March 2018 11:11:24 UTC-7, Didier wrote: > > I was hoping that ^:const would be able to inline any symbol value and > that it would do so before macroexpanssion so that: > > (def ^:const bar {:a 100}) > > (defmacro foo > [x] > (:a x)) > > (foo bar) > > Would return: > > 100 > > The same way that: > > (foo {:a 100}) > > does. > > Then I read that ^:const only inlines primitive values (which disappointed > me), but so I thought that this would work: > > (def ^:const bar 100) > > (defmacro foo > [x] > (+ 10 x)) > > (foo bar) > > but that also doesn't work. > > So now I believe that ^:const inlines after macroexpanssion. > > I feel it would be really cool to be able to factor some input to macros > into constants, is this something I could open a ticket for, to extend > ^:const so it can inline all literal values and also does the inlining > before macroexpanssion so that the above would work? > -- 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.