String.format could work; I would prefer to have an inline syntax for the string formatting rather than appending it at the end, but that's the major objection. The main goal was to have the strings be easy to write and to make it easy to have variations. I'm also trying to avoid eval-ing a string.
I have used closures elsewhere in the same program for similar effects, but I hadn't managed to wrap my head around how to format it for this particular application. Trying out something along the lines of the suggested code seems to work, I'll have to play around with it to see if it works for all of my use cases. Thanks for the help. On Tuesday, November 25, 2014 5:27:05 PM UTC-5, Gary Verhaegen wrote: > > Can you elaborate on what makes String.format not a good fit here? > > On Tuesday, 25 November 2014, James Reeves <ja...@booleanknot.com > <javascript:>> wrote: > >> Do you know about closures? So something like: >> >> (defn foo [arg1 arg2] >> (fn [state] (do-something-with state arg1 arg2))) >> >> - James >> >> On 25 November 2014 at 18:55, Isaac Karth <isaacka...@gmail.com> wrote: >> >>> I'm trying to build a string output system with functions that later >>> have a state passed to it, so that I can write something like (output >>> "The result of this example is: " (get :result)) and have it passed to >>> a parsing function that takes a state and calls the functions in the list, >>> something like (let [state] {:result "success"}](-> state (get >>> :result))). Basically, a delayed evaluation of the functions in the >>> list until they get the context later. >>> >>> I've gotten far enough that I can send an unevaluated list of >>> single-argument functions via(defmacro output [& data] `[~@data]) but >>> sending a function plus some arguments is trickier and I'm having trouble >>> working out the quoting and unquoting that needs to go on. >>> >>> Alternately, is there a better way to solve my original problem? >>> Basically, I want to have a concise and simple format to enter mostly text >>> with a few functions/variables and have it evaluated in a totally different >>> context later. Or maybe there's a parser or text processing library that >>> would handle this better? >>> >>> -- >>> 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. >>> >> >> -- >> 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. >> > -- 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.