This is related to the reader-related thread from a few days/weeks ago---

We've got a system for logging and querying logs with a little
mini-query language, that allows statements like this:

(query :collection (limit 3) (created-during 1000 4000) (= :some-attribute 4))

Part of the query macro walks the clauses and replaces the symbols it
recognizes with functions:

(defn replace-syms [tree]
  (postwalk #(case %
                     limit limit ;; replace the symbol limit with the
function limit, etc.
                     created-during created-during
                     ...)))

It does this replacement outside the return-value of the macro (i.e.
there's a "(let [replaced (do-replacement forms)] `(... ~@replaced
...))"), so what gets spliced in is references to the literal
functions).

This works fine from the repl, and in most contexts when run via lein
run. But if the code using the query is run inside an executor,
everything blows up, because the classloader can't find the
created_during function, following a chain of calls involving the
reader.

The solution was to change bare references to the functions to
syntax-quoted names of functions. But I found it surprising that the
reader was involved at all---and especially that the problem *only*
cropped up when using executors. What's going on? Is it sending a
textual representation of the code to the executor, which then has to
read it back in?

-- 
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.


Reply via email to