>From the description of your problem, it's not really clear to me why you insist on using strings. Why not use the functions directly? Functions can serve as keys in maps. Granted, it's a bit ugly to print. You could also build a map of string to function yourself. Not sure what the performance of that would be compared to going through resolve every time; I would bet on "faster" but without much confidence.
On Friday, 13 October 2017, <lawrence.krub...@gmail.com> wrote: > 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 <lawrence...@gmail.com> 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, lawrence...@gmail.com >>> 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 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 >>> --- >>> 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/d/optout. >>> >> -- > 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 > <javascript:_e(%7B%7D,'cvml','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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@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 > <javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');>. > 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 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.