Is there a way I can avoid hard-coding " "denormalize.pull-from-mysql"" ? I guess it doesn't matter, but it does seem a little inelegant.
On Thursday, October 12, 2017 at 9:54:36 PM UTC-4, Justin Smith wrote: > > you can use (symbol "denormalize.pull-from-mysql" "f") instead > > On Thu, Oct 12, 2017 at 6:34 PM <[email protected] <javascript:>> > wrote: > >> Nevermind. I found that this works, though I think it is ugly and >> inelegant: >> >> resolved-f (resolve (symbol (str "denormalize.pull-from-mysql/" >> f))) >> >> >> On Thursday, October 12, 2017 at 9:27:06 PM UTC-4, [email protected] >> wrote: >>> >>> At the REPL, this works perfectly: >>> >>> > (defn get-users [] [:susan :kwan]) >>> > >>> > (defn what-is-this-function [f] ((resolve (symbol f)))) >>> >>> > (what-is-this-function "get-users") >>> >[:susan :kwan] >>> >>> In an uberjar this does not work. I read somewhere that the runtime >>> name-space is different than the REPL namespace and different from the >>> namespace that exists while the compiler compiles the code. >>> >>> So how do I resolve the symbol correctly? >>> >>> I have functions that call a MySQL database, and each function is named >>> after a database table. Most of the mechanics of the call are the same, the >>> only thing different is the SQL. So I have functions such as "company" and >>> "user" and "product". I also have a function called (select). I call select >>> with one of the other functions, given as a string: >>> >>> (select "product") >>> >>> Inside of (select) I need to turn "product" into a resolved symbol that >>> I can call. >>> >>> Afterwards, I store the results in a map in an atom. I want to use the >>> database names as the keys. So "product" should be the key that holds the >>> results of the function "product". >>> >>> But what I need to do to correctly resolve the string to a function? >>> >>> >>> >>> >>> >>> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected] >> <javascript:> >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> [email protected] <javascript:> >> 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 [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
