nathanmarz / cascalog

Data processing on Hadoop without the hassle.
Other
1.38k stars 178 forks source link

Can't use refactor-nrepl middleware with cascalog #274

Closed bfabry closed 9 years ago

bfabry commented 9 years ago

Blows up inside of tools.analyzer I think. It seems to be due to a macro relying on the values of &env, which apparently change when inside the analyzer. My quick hacky fix is this modification to cascalog.logic.fn/-save-env:

(defn- save-env [bindings form]
  ;; cascalog.logic.fn/fn, not core/fn
  (let [form (with-meta (cons `fn (rest form))
               (meta form))
        namespace (str *ns*)
        savers (for [b bindings 
                     :when (instance? clojure.lang.Compiler$LocalBinding b)] ;;;; <== hacky workaround             
                    [(str (.sym b)) (.sym b)])
        env-form `(into {} ~(vec savers))]
    ;; without the print-dup, it sometimes serializes invalid code
    ;; strings (with subforms replaced with "#")
    [env-form namespace (binding [*print-dup* true] (pr-str form))]))
sritchie commented 9 years ago

Any idea on how this affects the performance of function serialization? Does everything still work well?

bfabry commented 9 years ago

Performance as in speed? I wouldn't expect it to make much difference. Time taken serializing the functions I wouldn't think is normally a consideration. Performance in terms of does it still work... well, it works for me :-)

Maybe a better option would be to wrap it in a try catch and skip over the method missing exceptions, then it will definitely work the same as it did previously.

But yeah, I don't really know enough about the magic that is the undocumented &env values to speculate too much :-)

sritchie commented 9 years ago

@bfabry happy to take a pull req if you're still interested :)