On Thu, Jul 11, 2013 at 6:48 PM, Zach Tellman <ztell...@gmail.com> wrote:
> Yeah, for safety's sake I need to macroexpand everything, which wipes out > the &env for internal macros. There might be a gentler way to do this, but > it's not obvious to me. If anyone has suggestions, I'd be interested in > hearing them. You can track the environment through expansion: https://github.com/bwo/conditions/blob/master/test/conditions/free_test.clj#L19 The core.async internals do something similar (or did at the time of release, that code has been rewritten, apparently). You're also missing some binding forms: proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (try (/ 1 0) (catch Exception x (set! x 2) x))))) (clojure.core/let [x (new proteus.Containers$L 1)] (do (try (. clojure.lang.Numbers (divide 1 0)) (catch Exception (.x x) (do (.set x 2) nil) (.x x))))) proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (letfn [(x [] 4)] (set! x 4) x)))) (clojure.core/let [x (new proteus.Containers$L 1)] (do (letfn* [x (fn* x ([] 4))] (do (.set x 4) nil) (.x x)))) > > Zach > > > On Thursday, July 11, 2013 6:35:21 PM UTC-7, Ben wrote: > >> Note: >> >> proteus> (defmacro aif [test then else] >> (let [it (first (filter #(not (contains? &env %)) >> ** (cons 'it (map #(symbol (str "it-" >> %)) (iterate inc 1)))))] >> `(let [~it ~test] (if ~it ~then ~else)))) >> #'proteus/aif >> proteus> (aif (get {:x {:y 3}} :x) >> (aif (get it :y) >> [it it-1] >> it) >> nil) >> [{:y 3} 3] >> proteus> (let-mutable [x 1] >> (aif (get {:x {:y 3}} :x) >> (aif (get it :y) >> ** (set! x [it it-1]) >> ** (set! x it)) >> (set! x nil)) >> x) >> CompilerException java.lang.RuntimeException: Unable to resolve symbol: >> it-1 in this context, compiling:(NO_SOURCE_PATH:1:1) >> proteus> >> >> >> >> >> On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman <ztel...@gmail.com> wrote: >> >>> There was some discussion a few days ago about how the lack of local >>> mutable variables were harming performance, or possibly elegance, I'm not >>> sure. Regardless, I fixed it: >>> https://github.com/**ztellman/proteus<https://github.com/ztellman/proteus> >>> >>> Enjoy! >>> >>> -- >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Clojure" group. >>> To post to this group, send email to clo...@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+u...@**googlegroups.com >>> >>> For more options, visit this group at >>> http://groups.google.com/**group/clojure?hl=en<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+u...@**googlegroups.com. >>> >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> >> >> -- >> Ben Wolfson >> "Human kind has used its intelligence to vary the flavour of drinks, >> which may be sweet, aromatic, fermented or spirit-based. ... Family and >> social life also offer numerous other occasions to consume drinks for >> pleasure." [Larousse, "Drink" entry] >> >> -- > -- > 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. > > > -- Ben Wolfson "Human kind has used its intelligence to vary the flavour of drinks, which may be sweet, aromatic, fermented or spirit-based. ... Family and social life also offer numerous other occasions to consume drinks for pleasure." [Larousse, "Drink" entry] -- -- 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.