Re: Callbacks as Sequences
Not sure it applies, but I found this very interesting: http://oobaloo.co.uk/clojure-from-callbacks-to-sequences Erik kl. 19:45:36 UTC+1 onsdag 6. februar 2013 skrev da...@dsargeant.com følgende: > > I'm not to clojure/clojurescript and was wondering if anyone has taken a > crack at writing a macro that transforms callbacks into a sequence. There > is an awesome implementationion in LispyScript show here: > https://gist.github.com/santoshrajan/3715526. Thanks for help. > > David > -- -- 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.
Re: Callbacks as Sequences
Thanks, but I'm looking for something that would let me sent strings between programs on localhost. On Wednesday, 6 February 2013 22:17:02 UTC-5, Feng Shen wrote: > > I did something for a http lib: > > ;; get them concurrently(let [response1 (http/get "http://http-kit.org/";) > response2 (http/get "http://clojure.org/";)] > ;; handle responses one-by-one, waiting for response as necessary > ;; other keys :headers :status :error :opts > (println "response1: " (:body @response1)) > (println "response2: " (:body @response2))) > > > > On Thursday, February 7, 2013 2:45:36 AM UTC+8, da...@dsargeant.com wrote: >> >> I'm not to clojure/clojurescript and was wondering if anyone has taken a >> crack at writing a macro that transforms callbacks into a sequence. There >> is an awesome implementationion in LispyScript show here: >> https://gist.github.com/santoshrajan/3715526. Thanks for help. >> >> David >> > -- -- 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.
Re: Callbacks as Sequences
I did something for a http lib: ;; get them concurrently(let [response1 (http/get "http://http-kit.org/";) response2 (http/get "http://clojure.org/";)] ;; handle responses one-by-one, waiting for response as necessary ;; other keys :headers :status :error :opts (println "response1: " (:body @response1)) (println "response2: " (:body @response2))) On Thursday, February 7, 2013 2:45:36 AM UTC+8, da...@dsargeant.com wrote: > > I'm not to clojure/clojurescript and was wondering if anyone has taken a > crack at writing a macro that transforms callbacks into a sequence. There > is an awesome implementationion in LispyScript show here: > https://gist.github.com/santoshrajan/3715526. Thanks for help. > > David > -- -- 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.
Re: Callbacks as Sequences
I've seen that and think it's awesome. This would be used for Node.js. I whipped this up to show what a Clojure version might look like. Basically each body form after the first is inserted where (cb) is found in the previous form. ; Definition (defmacro defseq [fn-name params & body]) ; Example usage (defseq request-handler [req resp] ((. resp (set-header "Content-Type" "text/html")) (exists "some-file.txt" (cb))) (fn [exists] (if exists (read-file filename "utf8" (cb)) (. resp (end "File Not Found" (fn [err data] (if err (. resp (end "Internal Server Error")) (. resp (end data) On Wednesday, February 6, 2013 2:13:33 PM UTC-5, Max Penet wrote: > > Hi, > > jayq includes something similar (nicer imho). It takes the form of a let > like construct > > (let-deferred > [a (jq/ajax "http://localhost:8000/1.json";) > b (jq/ajax "http://localhost:8000/2.json";)] (do-something-with-result > (merge a b foo))) > > It also supports :let and :when intermediary steps. > > more examples can be found here: > https://github.com/ibdknox/jayq#jayqmacros-source > > and the macro: > https://github.com/ibdknox/jayq/blob/master/src/jayq/macros.clj#L15 > https://github.com/ibdknox/jayq/blob/master/src/jayq/core.cljs#L516 > > > Max > > On Wednesday, February 6, 2013 7:45:36 PM UTC+1, da...@dsargeant.comwrote: >> >> I'm not to clojure/clojurescript and was wondering if anyone has taken a >> crack at writing a macro that transforms callbacks into a sequence. There >> is an awesome implementationion in LispyScript show here: >> https://gist.github.com/santoshrajan/3715526. Thanks for help. >> >> David >> > -- -- 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.
Re: Callbacks as Sequences
Hi, jayq includes something similar (nicer imho). It takes the form of a let like construct (let-deferred [a (jq/ajax "http://localhost:8000/1.json";) b (jq/ajax "http://localhost:8000/2.json";)] (do-something-with-result (merge a b foo))) It also supports :let and :when intermediary steps. more examples can be found here: https://github.com/ibdknox/jayq#jayqmacros-source and the macro: https://github.com/ibdknox/jayq/blob/master/src/jayq/macros.clj#L15 https://github.com/ibdknox/jayq/blob/master/src/jayq/core.cljs#L516 Max On Wednesday, February 6, 2013 7:45:36 PM UTC+1, da...@dsargeant.com wrote: > > I'm not to clojure/clojurescript and was wondering if anyone has taken a > crack at writing a macro that transforms callbacks into a sequence. There > is an awesome implementationion in LispyScript show here: > https://gist.github.com/santoshrajan/3715526. Thanks for help. > > David > -- -- 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.
Callbacks as Sequences
I'm not to clojure/clojurescript and was wondering if anyone has taken a crack at writing a macro that transforms callbacks into a sequence. There is an awesome implementationion in LispyScript show here: https://gist.github.com/santoshrajan/3715526. Thanks for help. David -- -- 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.