strange map
Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- 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: strange map
Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcppu...@gmail.com Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- 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. -- -- 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: strange map
map is lazy. You shouldn't call side effect functions from it. I recommend you use doseq instead. On Wed, Aug 28, 2013 at 1:57 AM, Christian Sperandio christian.speran...@gmail.com wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcppu...@gmail.com Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- 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. -- -- 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. -- -- 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: strange map
Hi, Nothing to get, Nothing to println, please give a detail, thank you. On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com javascript: Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: strange map
Right, thank you! On Wednesday, August 28, 2013 4:59:33 PM UTC+8, Alex Baranosky wrote: map is lazy. You shouldn't call side effect functions from it. I recommend you use doseq instead. On Wed, Aug 28, 2013 at 1:57 AM, Christian Sperandio christian...@gmail.com javascript: wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com javascript: Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: strange map
Hi user= (def r (map #(do (print -) %) '(1 2 3 4 5))) #'user/r user= (println r) (--1 -2 -3 -4 5) nil On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com javascript: Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: strange map
Hi user= (def r (map #(do (print -) %) '(1 2 3 4 5))) #'user/r user= (println r) (--1 -2 -3 -4 5) nil On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com javascript: Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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: strange map
In fact, you mix the output in the REPL and the result of the map function. The result of the map call is (1 2 3 4 5), but you have the print display is managed by the repl and is done when is done :) If you want as result a string with the negative value, you must do: (map #(str - %) '(1 2 3 4 5)) 2013/8/28 ljcppu...@gmail.com Hi user= (def r (map #(do (print -) %) '(1 2 3 4 5))) #'user/r user= (println r) (--1 -2 -3 -4 5) nil On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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. -- -- 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: eval/macros with functions with metadata
what's the use case for evaling a function object? On Tue, Aug 27, 2013 at 8:54 PM, Ben Wolfson wolf...@gmail.com wrote: or, the dreaded no matching ctor found exception. Is there a way to write the function (defn eval-at-one [f] (eval `(~f 1))) such that it works when invoked like this: (eval-at-one (fn [x] x)) ;; -- 1 and like this (eval-at-one (with-meta (fn [x] x) {})) ;; - IllegalArgumentException No matching ctor found for class clojure.lang.AFunction$1 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) ? I thought that the object returned by with-meta might be hanging onto the original, metadata-less object, which could then be retrieved and used without difficulty, but this appears not to be the case. -- 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. -- Gary Fredericks (803)-295-0195 fredericksg...@gmail.com www.gfredericks.com -- -- 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: Easiest way to map over leaf nodes of nested sequence
the function cleans up slightly with cond-. I don't think you can get around having to specify how to recognize a leaf, for any general solution. On Tue, Aug 27, 2013 at 10:27 PM, JvJ kfjwhee...@gmail.com wrote: I suppose that works, but it seems a little inelegant to do this: (prewalk #(if (sequential? %) % (f %)) xs) instead of just (prewalk f xs) On Tuesday, 27 August 2013 20:06:38 UTC-7, gfredericks wrote: Clojure.walk On Aug 27, 2013 10:05 PM, JvJ kfjwh...@gmail.com wrote: I feel like this question has been asked about a trillion times, but I was having a hard time finding a straight answer. Is there a really straightforward way in the standard library or in one of the contrib libraries to do something like this: (nested-map inc '(1 (2 3) (4 (5 (6) === '(2 (3 4) (5 (6 (7 -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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. -- Gary Fredericks (803)-295-0195 fredericksg...@gmail.com www.gfredericks.com -- -- 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: [ANN] nativot 0.1.0 (leiningen plugin) public beta
Plugin homepage: https://bitbucket.org/noncom/nativot As for the license: I have contacted JDotSoft, they're kindly giving the green light! I am providing link to this post, so they can join the discussion. Also, in the next version I am going to update the plugin and include the current version of JarClassLoader from the website, so it can be used if no internet is available. However, if internet is available, the plugin will still contact the website and download the class, even if it is not newer than the bundled version. -- -- 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: strange map
I'm pretty sure the OP is experimenting to see when items are realized, and wants to know why it's peeking ahead one item. Most likely map is seeing if the next part is empty. On Wed, Aug 28, 2013 at 5:39 AM, Christian Sperandio christian.speran...@gmail.com wrote: In fact, you mix the output in the REPL and the result of the map function. The result of the map call is (1 2 3 4 5), but you have the print display is managed by the repl and is done when is done :) If you want as result a string with the negative value, you must do: (map #(str - %) '(1 2 3 4 5)) 2013/8/28 ljcppu...@gmail.com Hi user= (def r (map #(do (print -) %) '(1 2 3 4 5))) #'user/r user= (println r) (--1 -2 -3 -4 5) nil On Wednesday, August 28, 2013 4:57:49 PM UTC+8, Christian Sperandio wrote: Hi, Try just one thing: (def r (map #(do (print -) %) '(1 2 3 4 5))) And after, do (println r) What do you get? 2013/8/28 ljcp...@gmail.com Hi (map #(do (print -) %) '(1 2 3 4 5)) I think the result should be (-1 -2 -3 -4 -5), but it is (--1 -2 -3 -4 5), it's difficult to understand, Can someone give answer? -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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. -- -- 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. -- -- 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: Can you explain the result of a expression?
http://stackoverflow.com/questions/12412038/in-clojure-are-lazy-seqs-always-chunked -- -- 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: Rxjava + Clojure Users
On Tuesday, August 27, 2013 6:03:29 PM UTC+2, daveray wrote: Hi. I'm writing to see if there's anyone out there using RxJava [1] from Clojure and to get their opinion on it's current, built-in support for non-Java languages. Just to recap, the current implementation knows about clojure.lang.IFn allowing functions to be passed directly to RxJava methods: (- my-observable (.map (fn [v] (Long/parseLong v))) (.reduce +)) RxJava will automatically convert these functions to the underlying rx.util.functions.FuncX interface and re-dispatch to the appropriate method. So, the question is: as a user of RxJava, how valuable is this feature? Do you just end up wrapping things anyway, We are using RxJava and Hystrix with Clojure @ SoundCloud. All our Observables come from Hystrix cmds. I've have not added any wrappers around the RxJava stuff yet, not really felt the need. I've found it convenient to pass in fns but I would also be happy with what you suggest below (rx/fn). I suspect in those cases I might start wrapping rx/fn, so it continues to look like the current behaviour (recognising Clojure fns). Thanks, -- Joseph Wilk http://blog.josephwilk.net @josephwilk so you could easily perform the same transformation in your wrapper? Would helper fns/macros be a sufficient alternative: (- my-observable (.map (rx/fn [v] (Long/parseLong v))) (.reduce (rx/fn* +))) There will be some changes in this area in the near future and we'd like to get a feel for if/how people are using RxJava from Clojure. Thanks! Dave [1] https://github.com/Netflix/RxJava -- -- 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.
stringify the name of an interned function
Hello, I am new to clojure, and I am trying to define a function that turns a function-name into a string, but I am stuck. Here is what I tried: user (defn some-func [] true) I am looking for a function stringify that would do the following user (stringify some-func) some-func I can do it with var as long it is not wrapped in a defn-form: user (second (clojure.string/split (str (var some-func)) #/)) some-func However, if I try to put it into a defn, I get an error: user (defn stringify [func] (second (clojure.string/split (str (var func)) #/))) CompilerException java.lang.RuntimeException: Unable to resolve var: func in this context, compiling:(/tmp/form-init6959523461952831160.clj:2:37) What am I missing here? Thanks in advance... -- -- 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: stringify an interned function
Jim wrote: or convert it to a macro and it should work as you hoped :) (defmacro stringify [f] `(- ~f var meta :name str)) Coool! Thank you again! EM HTH, Jim On 27/08/13 13:26, Jim wrote: On 27/08/13 13:13, Jim wrote: (defn stringify [func] (- func var meta :name str)) I'm sorry this won't work...try this: (defn stringify [fvar] (- fvar meta :name str)) and pass in the var object like this: (stringify (var some-func)) OR (stringify #'some-func) btw, you will only get the name not the namespace it belongs in... Jim -- -- 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: stringify an interned function
Jim wrote: On 27/08/13 10:39, Erebus Mons wrote: I am looking for a function stringify that would do the following user (stringify some-func) some-func (- #'some-func meta :name str) (defn stringify [func] (- func var meta :name str)) This gives me the same error in the function: user (defn stringify [func] (- func var meta :name str)) CompilerException java.lang.RuntimeException: Unable to resolve var: func in this context, compiling:(/tmp/form-init6959523461952831160.clj:2:3) user *clojure-version* {:major 1, :minor 5, :incremental 1, :qualifier nil} user Jim -- -- 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: learning records and namespaces
What is field ? a symbol ? of what ? Is it defined as a Storable ? if fle is just a symbol, so (save Symbol) is not defined. And (.save Symbol) he can't find the link in Symbol Protocol (?) for save... What did you try to do with this poor Symbol ? -- -- 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.
[ANN] Immutant 1.0.1 released
Hi all, We addressed the bugs reported against 1.0.0, improved our Leiningen integration, and added some minor enhancements to our messaging and cache namespaces. I've also bumped the OpenShift Immutant cartridge version to 1.0.1. Details here: http://bit.ly/imm101 Thanks, Jim -- -- 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.
ClojureScript: Keyword Breaking Change Around the Corner
ClojureScript has long represented symbols and keywords as JavaScript Strings as a performance optimization around hash maps. However modern JavaScript engines have shown that following Clojure JVM's design more closely consistently delivers better performance. Also the representation of keywords as strings has had an unfortunate consequence, we modify the String prototype to allow keywords to be called as functions - this is a serious interop liability. Sean Grove has done some excellent work that I have further extended in a branch. In this branch keywords are represented with a deftype. In order to deliver performance, under advanced optimizations we emit keywords constants to avoid allocation overheads. The breaking change is that keywords in ClojureScript cannot support the identical? property guaranteed by Clojure on the JVM. There is a new equality check called keyword-identical? that can be used to efficiently check for keyword equality. defrecords and hash maps have been updated to use this predicate. Please try your projects with this branch so we can address any further issues because of this breaking change. http://github.com/clojure/clojurescript/compare/keywords Thanks, 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.
London Clojure eXchange 6 December 2013
Fellow Clojurians, After the success of last years London Clojure eXchange (videos here: http://skillsmatter.com/event/clojure/clojure-exchange-2012) I'd like to announce the Call for Presentations for this years London Clojure eXchange. It will again be in London and on 6 December. SkillsMatter will be our wonderful hosts. We're running a quick call for presentations due to everyone else having a call for presentations out at the moment. I'd like to close the CfP on midnight 14 September. We'll be announcing the rest of the presentations the following week. Please submit your papers by emailing me at b...@otfrom.com If you'd like to attend the conference the sign up page for this year's conference is here: http://skillsmatter.com/event/java-jee/clojure-exchange-2013 I look forward to seeing all of you in London at the beginning of December! cheers, Bruce -- @otfrom | CTO co-founder @MastodonC | mastodonc.com See recent coverage of us in the Economist http://econ.st/WeTd2i and the Financial Times http://on.ft.com/T154BA -- -- 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: stringify the name of an interned function
erebus.m...@gmail.com writes: What am I missing here? Functions don't really have names. A function may be bound to a var, and that has a name (:name metadata, to be precise). That said, since function's get compiled to classes you could twiddle with the class name. user (defn fnname [f] (symbol (clojure.string/replace-first (.getName (class f)) $ /))) #'user/fnname user (let [f partition] (fnname f)) clojure.core/partition user (let [f fnname] (fnname f)) user/fnname user (let [f (fn [])] (fnname f)) user/eval1301$f__1302 user (let [foo (fn [])] (fnname foo)) user/eval1327$foo__1328 user (let [foo (fn bar [])] (fnname foo)) user/eval1333$bar__1334 user (letfn [(foobar [])] (fnname foobar)) user/eval1371$foobar__1372 For what do you need that? Bye, Tassilo -- -- 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: London Clojure eXchange 6 December 2013
Oops! I forgot. We'll be doing longer 35 (min talks) and some shorter 10 minute talks. Please say what length you would like as a part of your proposal. Please include a title, synopsis and a short biography of yourself and the running time for your talk. cheers, Bruce On Wed, Aug 28, 2013 at 2:52 PM, Bruce Durling b...@otfrom.com wrote: Fellow Clojurians, After the success of last years London Clojure eXchange (videos here: http://skillsmatter.com/event/clojure/clojure-exchange-2012) I'd like to announce the Call for Presentations for this years London Clojure eXchange. It will again be in London and on 6 December. SkillsMatter will be our wonderful hosts. We're running a quick call for presentations due to everyone else having a call for presentations out at the moment. I'd like to close the CfP on midnight 14 September. We'll be announcing the rest of the presentations the following week. Please submit your papers by emailing me at b...@otfrom.com If you'd like to attend the conference the sign up page for this year's conference is here: http://skillsmatter.com/event/java-jee/clojure-exchange-2013 I look forward to seeing all of you in London at the beginning of December! cheers, Bruce -- @otfrom | CTO co-founder @MastodonC | mastodonc.com See recent coverage of us in the Economist http://econ.st/WeTd2i and the Financial Times http://on.ft.com/T154BA -- @otfrom | CTO co-founder @MastodonC | mastodonc.com See recent coverage of us in the Economist http://econ.st/WeTd2i and the Financial Times http://on.ft.com/T154BA -- -- 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.
ANN: core.logic 0.8.4
From 0.8.3 to 0.8.4 Fixes * Allow fd/in to appear in any position * LOGIC-127: nom-swapping now preserves vectors and maps * LOGIC-132: proper recursive featurec * LOGIC-139: fix unification on relations Changes * membero now uses disequality constraint * docstring enhancements http://github.com/clojure/core.logic 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: ClojureScript: Keyword Breaking Change Around the Corner
Will identical? correctly handle keywords under advanced compilation, with keywords constants emited? On Wed, Aug 28, 2013 at 3:29 PM, David Nolen dnolen.li...@gmail.com wrote: ClojureScript has long represented symbols and keywords as JavaScript Strings as a performance optimization around hash maps. However modern JavaScript engines have shown that following Clojure JVM's design more closely consistently delivers better performance. Also the representation of keywords as strings has had an unfortunate consequence, we modify the String prototype to allow keywords to be called as functions - this is a serious interop liability. Sean Grove has done some excellent work that I have further extended in a branch. In this branch keywords are represented with a deftype. In order to deliver performance, under advanced optimizations we emit keywords constants to avoid allocation overheads. The breaking change is that keywords in ClojureScript cannot support the identical? property guaranteed by Clojure on the JVM. There is a new equality check called keyword-identical? that can be used to efficiently check for keyword equality. defrecords and hash maps have been updated to use this predicate. Please try your projects with this branch so we can address any further issues because of this breaking change. http://github.com/clojure/clojurescript/compare/keywords Thanks, 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. -- -- 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: eval/macros with functions with metadata
On Wed, Aug 28, 2013 at 2:46 AM, Gary Fredericks fredericksg...@gmail.comwrote: what's the use case for evaling a function object? This is just a minimal example that illustrates the difficulty, in the actual code where I came across it, a new function with relatively complex internals is created at runtime. -- 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.
Eval vs the repl
I had previously assumed that the clojure repl effectively just did (eval (read-string input)). That doesn't seem to be the case eg: user [do (inc 1)] CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:1:1) user (eval '[do (inc 1)]) 2 nil user (load-string [do (inc 1)]) 2 nil user ^{:line 11, :column 20} [] [] nil user (eval ^{:line 11, :column 20} []) ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) user (load-string ^{:line 11, :column 20} []) ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) What can I do to eval a string in the same way that the repl does? -- -- 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: eval/macros with functions with metadata
Clojure struggles with staged programming because of JVM limitations. The deeper issue here is that JVM bytecode is fundamentally static: it's not allowed to contain references to objects that only exist at runtime. In languages that have a built-in concept of a runtime image, like Smalltalk or some Lisps, the line between static code and runtime data is blurred. https://groups.google.com/forum/#!searchin/clojure/eval$20closure/clojure/scAjN7_Xig0/bfWuWnzX7z4J https://groups.google.com/forum/#!searchin/clojure/eval$20closure/clojure/eQpeivDn-Vg/Jv29pOd0BgwJ https://groups.google.com/d/topic/clojure/jPGu5MUsGBs/discussion If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. On 28 August 2013 15:17, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 2:46 AM, Gary Fredericks fredericksg...@gmail.com wrote: what's the use case for evaling a function object? This is just a minimal example that illustrates the difficulty, in the actual code where I came across it, a new function with relatively complex internals is created at runtime. -- 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. -- -- 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: eval/macros with functions with metadata
On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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.
Re: Eval vs the repl
What repl are you using? I think it's doing something weird. java -cp clojure-1.5.1.jar clojure.main user= [do (inc 1)] 2 user ^{:line 11, :column 20} [] ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) --Aaron -- -- 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: Eval vs the repl
Huh, I'm using nrepl.el but if I use lein repl I get the same results as you. On 28 August 2013 18:16, Aaron Cohen aa...@assonance.org wrote: What repl are you using? I think it's doing something weird. java -cp clojure-1.5.1.jar clojure.main user= [do (inc 1)] 2 user ^{:line 11, :column 20} [] ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) --Aaron -- -- 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. -- -- 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: eval/macros with functions with metadata
You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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: eval/macros with functions with metadata
I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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. -- -- 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: Eval vs the repl
On Wednesday, August 28, 2013 12:13:54 PM UTC-4, Jamie Brandon wrote: user [do (inc 1)] Just curious: what do you expect that to do? To me it looks like a 2-element vector... (containing a `do` special form and then the value 2), but my repl yields 2 as the result (?). -- -- 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.
[ANN] Criterium 0.4.2 released
Criterium 0.4.2 has been released [1], and is on clojars. The only update is to issue a warning if TieredStopAtLevel is found in the JVM arguments. Hopefully this will help alert people trying to optimise code using lein's default JVM arguments. Criterium measures the computation time of an expression. It is designed to address some of the pitfalls of benchmarking, and benchmarking on the JVM in particular. Hugo [1] https://github.com/hugoduncan/criterium signature.asc Description: PGP signature
Re: eval/macros with functions with metadata
That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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. -- -- 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
Re: eval/macros with functions with metadata
How about this alternative? (deftype Wrapper [f] clojure.lang.IFn (invoke [this] (f)) (invoke [this a] (f a)) ; repeat until you get bored ) (defn e [f] (let [wr (Wrapper. f)] (eval `(~wr 1 (e inc) (e (with-meta (fn [x] (+ 4 x)) {})) On Wed, Aug 28, 2013 at 1:59 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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
Re: eval/macros with functions with metadata
Sorry, that one doesn't work. It worked in my repl, but I must have been using old code. On Wed, Aug 28, 2013 at 2:27 PM, Aaron Cohen aa...@assonance.org wrote: How about this alternative? (deftype Wrapper [f] clojure.lang.IFn (invoke [this] (f)) (invoke [this a] (f a)) ; repeat until you get bored ) (defn e [f] (let [wr (Wrapper. f)] (eval `(~wr 1 (e inc) (e (with-meta (fn [x] (+ 4 x)) {})) On Wed, Aug 28, 2013 at 1:59 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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
Re: eval/macros with functions with metadata
This is a little hard for me to follow because I'm not sure what graph or output-in are doing. If the letfn is being generated by your compilation step, why can't that go inside of your generated fn rather than outside it? (clojure.core/fn [input__2288__auto__] (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (num input__2288__auto__))) On Wed, Aug 28, 2013 at 1:59 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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. -- -- 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
Re: eval/macros with functions with metadata
Sorry, I guess that wasn't very clear. Let's put a really simple example with just the pattern-matching subset: strucjure.regression.sandbox= (def p (pattern [1 ^x _ 3])) #'strucjure.regression.sandbox/p strucjure.regression.sandbox= p [1 #strucjure.pattern.Bind{:symbol x, :pattern #strucjure.pattern.Any{}} 3] strucjure.regression.sandbox= (def o (output ~p (fnk [x] x))) #'strucjure.regression.sandbox/o strucjure.regression.sandbox= o #strucjure.pattern.Output{:pattern [1 #strucjure.pattern.Bind{:symbol x, :pattern #strucjure.pattern.Any{}} 3], :fnk # clojure.lang.AFunction$1@18ab1e1c} strucjure.regression.sandbox= ((view ~p) [1 2 3]) [[1 2 3] nil] strucjure.regression.sandbox= ((view ~o) [1 2 3]) [2 nil] strucjure.regression.sandbox= (pprint (macroexpand-1 '(view ~o))) (fn [input3910] (clojure.core/when (clojure.core/vector? input3910) (clojure.core/when (clojure.core/= (clojure.core/count input3910) 3) (clojure.core/let [input-sym3911 (clojure.core/nth input3910 0)] (clojure.core/when (clojure.core/= input-sym3911 '1) (clojure.core/let [input-sym3912 (clojure.core/nth input3910 1)] (clojure.core/let [x input-sym3912] (clojure.core/let [input-sym3913 (clojure.core/nth input3910 2)] (clojure.core/when (clojure.core/= input-sym3913 '3) [(#sandbox$fn__3090$pos_fn__1649__auto3091 strucjure.regression.sandbox$fn__3090$pos_fn__1649__auto3091@62b1f96f x) (clojure.core/seq (clojure.core/subvec input3910 3))]) You can see towards the end of the generated code where it calls the fnk directly as #sandbox$fn__3090... The motivation here is that you can define the grammar for a language once and then make different transformations by attaching output fnks. It would be very useful if those output fnks could be closures. It's not obvious in this small example but the compiler produces some important optimisations, otherwise I could just interpret the grammar and there would be no problem. In general, for staged programming it's useful to be able to pass arbitrary data between stages eg metaocaml (http://okmij.org/ftp/ML/MetaOCaml.html) often passes refs between stages. I think some of the terra (http://terralang.org/) examples pass closures too. On 28 August 2013 20:54, Aaron Cohen aa...@assonance.org wrote: This is a little hard for me to follow because I'm not sure what graph or output-in are doing. If the letfn is being generated by your compilation step, why can't that go inside of your generated fn rather than outside it? (clojure.core/fn [input__2288__auto__] (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (num input__2288__auto__))) On Wed, Aug 28, 2013 at 1:59 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wolf...@gmail.com wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the
Re: Eval vs the repl
I think you may be tripping over this bug: http://dev.clojure.org/jira/browse/CLJ-1184 which is waiting for Rich's approval to go into 1.6. Alex On Wednesday, August 28, 2013 11:13:54 AM UTC-5, Jamie Brandon wrote: I had previously assumed that the clojure repl effectively just did (eval (read-string input)). That doesn't seem to be the case eg: user [do (inc 1)] CompilerException java.lang.RuntimeException: Unable to resolve symbol: do in this context, compiling:(NO_SOURCE_PATH:1:1) user (eval '[do (inc 1)]) 2 nil user (load-string [do (inc 1)]) 2 nil user ^{:line 11, :column 20} [] [] nil user (eval ^{:line 11, :column 20} []) ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) user (load-string ^{:line 11, :column 20} []) ClassCastException java.lang.Long cannot be cast to java.lang.Integer clojure.lang.Compiler.eval (Compiler.java:6597) What can I do to eval a string in the same way that the repl does? -- -- 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.
Emacs Clojure mode : No syntax highlighting for #_
Although semicolons cause the text color to change in order to look commented-out, the #_ reader macro doesn't cause any such change. Is this intended, or is it a bug? -- -- 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: [ANN] core.typed 0.2.0 - Production Ready
Awesome. Thanks for your hard work! Allen On Wednesday, August 28, 2013 3:28:35 PM UTC-7, Ambrose Bonnaire-Sergeant wrote: Hi, After 10 months and 26 0.1.x releases of transitioning core.typed from an ambitious student project, I am finally comfortable recommending core.typed for production use. Production Ready My interpretation of production ready in this context is: - core.typed can *find bugs* in real code - core.typed will *not slow down* your existing code by loading a large library at production. (core.typed does introduce an extra identity-like function call at type annotations, I assume this is a candidate for optimisation via HotSpot) - A basic *tutorial*, API docs and example project exist - core.typed is *currently used in production* with success (at CircleCI for several months) - The core type checking API is mostly *stable*, with only very minor removals/breaking changes in the last few months. There are several outstanding issues, but I am satisfied that core.typed can bring real utility to real programs *today* and with *no production-time drawbacks*, thus this release. How to get started Leiningen dep: [org.clojure/core.typed 0.2.0] ...; for very recent releases:repositories {sonatype-oss-public https://oss.sonatype.org/content/groups/public/} If you like following tutorials try the user/types guide. If you just want to get your hands on some typed code, see the Example project. core.typed User Guidehttps://github.com/clojure/core.typed/wiki/User-Guide core.typed Types Guide https://github.com/clojure/core.typed/wiki/Types Example project https://github.com/frenchy64/core.typed-example API Reference http://clojure.github.io/core.typed/ core.typed Github Home https://github.com/clojure/core.typed core.typed Wiki https://github.com/clojure/core.typed/wiki Please report bugs, ask questions or discuss things on the mailing listhttps://groups.google.com/forum/?fromgroups#!forum/clojure-core-typed . (FWIW I'm ambrosebs on #clojure.) Thanks, Ambrose -- -- 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.
[ANN] Cloc 0.1.0 - Leiningen plugin to serve project API docs through a local web server
Hi! Cloc is a small web app to serve API documentation, packaged as a Leiningen plugin. The idea is that you run one command, `lein cloc` from any Leiningen project and it fires up a local web server with all the documentation you'll need, for your own code and for the dependencies in your project file. It also has a Lucene-powered search built in. A first release is available on Clojars, instructions and a screenshot are on the GitHub project [1] for anyone who wants to give it a try. A ton of things need improvement, fixing, rewriting... I'll add a comprehensive list of upcoming features and known bugs to the GitHub issue tracker tomorrow. Meanwhile, the main problem you're likely to encounter is that it only works in Chrome -- browser compatibility fixes are on the way! Feedback and suggestions welcome - feel free to add things to the GitHub issues page! Jaley. [1] http://github.com/jaley/cloc -- -- 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: ClojureScript: Keyword Breaking Change Around the Corner
Will identical? correctly handle keywords under advanced compilation, with keywords constants emited? The missing part of your question is: What about dynamically constructed keywords? When the constant table provided by this patch is enabled, all keywords statically present in source code will test identical? to other keywords that come from elsewhere in the source. At compile time, all keywords will be replaced with namespace.dotted.field.lookups. The real question is what happens when you construct keywords using the cljs.core/keyword function? Well there are two subcategories: 1) Keywords that already exist in the constant table 2) Never before seen keywords For #1, we *can* look them up in the constant table and return those instances, which will produce keywords that test identical? against source-level or other dynamically-created, but elsewhere-in-source keywords. I'm not sure if this branch does that (or if it should). For #2, we can't intern the keywords like Clojure does on the JVM because JavaScript does not provide weak references. If we interned dynamically created keywords, then we'd have an exploitable memory leak. -- -- 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: Emacs Clojure mode : No syntax highlighting for #_
On Wednesday, August 28, 2013 6:09:11 PM UTC-4, JvJ wrote: Although semicolons cause the text color to change in order to look commented-out, the #_ reader macro doesn't cause any such change. Is this intended, or is it a bug? I see this as well with the version of clojure-mode I've installed from marmalade via M-x package-install. -- -- 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: Emacs Clojure mode : No syntax highlighting for #_
I would imagine it is intended since *#_* is a reader macro. *#_* is not intended for commenting. Rather, it instructs the Clojure Reader to ignore entirely the subsequent form. This is much different from the *comment*macro (which simply takes any number of arguments and returns nil) or the *;* comment syntax. It might be a bit involved to have *#_* and the subsequent form appear commented through clojure-mode's syntax highlighting. However, it would also incorrectly express the semantics of *#_* which, arguably, is counter to the goal of syntax highlighting. On Wednesday, August 28, 2013 3:09:11 PM UTC-7, JvJ wrote: Although semicolons cause the text color to change in order to look commented-out, the #_ reader macro doesn't cause any such change. Is this intended, or is it a bug? -- -- 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.
To read and write bytes via Socket
Hello all. Please help me to read and write bytes via Socket. For example, assumed that I want to send 5 bytes [0x00, 0x01, 0x7f, 0x80, 0xff] to a TCP server. I did: (require '[clojure.java.io :refer :all]) (with-open [s (java.net.Socket. *ip.of.test.server* *port_of_test_server* )] (let [^java.io.BufferedWriter wtr (writer s) ^chars obuf (char-array (map char [0 1 127 128 255]))] (.write wtr obuf 0 5) (.flush wtr Then, my test server received bytes: [0x00, 0x01, 0x7f, 0xc2, 0x80, 0xc3, 0xbf]. * I think I should use a char array so that read() requires 'char[]'. * What is the valid char value to send a byte 0x80? * How can I make the char value from 0x80 int? * How are things about read. * Does character encoding environment affect? (I use -Dfile.encoding=UTF-8) Thank you in advance. Yoshinori Kohyama -- -- 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: To read and write bytes via Socket
With UTF-8 characters are encoded in a variable number of bytes according to various ranges, as you can see here in section Description: http://en.wikipedia.org/wiki/UTF-8 Since you're sending your bytes as chars but read back as bytes, your last two bytes create chars that later produce two bytes each, and thus you see seven bytes at the other end. You may want to get an output stream from the socket and write single bytes directly. On Wednesday, August 28, 2013 7:13:31 PM UTC-7, Yoshinori Kohyama wrote: Hello all. Please help me to read and write bytes via Socket. For example, assumed that I want to send 5 bytes [0x00, 0x01, 0x7f, 0x80, 0xff] to a TCP server. I did: (require '[clojure.java.io :refer :all]) (with-open [s (java.net.Socket. *ip.of.test.server* *port_of_test_server *)] (let [^java.io.BufferedWriter wtr (writer s) ^chars obuf (char-array (map char [0 1 127 128 255]))] (.write wtr obuf 0 5) (.flush wtr Then, my test server received bytes: [0x00, 0x01, 0x7f, 0xc2, 0x80, 0xc3, 0xbf]. * I think I should use a char array so that read() requires 'char[]'. * What is the valid char value to send a byte 0x80? * How can I make the char value from 0x80 int? * How are things about read. * Does character encoding environment affect? (I use -Dfile.encoding=UTF-8) Thank you in advance. Yoshinori Kohyama -- -- 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: eval/macros with functions with metadata
Sounds interesting, I'd love to hear more about the use case. We ran into this issue as well when implementing the new positional compilation for Graph. We filed a ticket [1], and worked around it with a funny trick: Suppose you want to eval a complicated thing, and the crux of the issue is that this fails: (let [y 1 f (fn [x] (+ x y))] (eval `(~f 1))) A solution is to rework what you eval, so that it has a 'hole' for the function and you slot the function into this hole afterwards (which Hotspot seems to be able to optimize just fine): (let [y 1 f (fn [x] (+ x y))] ((eval `(fn [g#] (g# 1))) f)) Happy to elaborate if you like. Cheers, Jason [1] http://dev.clojure.org/jira/browse/CLJ-1206 On Wednesday, August 28, 2013 10:59:19 AM UTC-7, Jamie Brandon wrote: That sort of works for my use case. What I want to do is define a grammar... (def num-graph (graph num ~(or ~succ ~zero) succ (succ ^x ~num) zero zero)) ... attach actions (def num-out (output-in num-graph 'zero (fnk [] 0) 'succ (fnk [x] (inc x ... and compile the result ... strucjure.regression.tests (graph-view 'num num-out) (clojure.core/letfn [(num ...) (succ ...) (zero ...)] (clojure.core/fn [input__2288__auto__] (num input__2288__auto__))) This works fine as long as the fnks dont close over anything, but that's very limiting. If I eval that code and *then* wrap it in (binding ...) I can have closures but that now means that I can't do call-site compilation. I'll have to poke around a bit more... On 28 August 2013 18:32, Aaron Cohen aa...@assonance.org javascript: wrote: I'm not sure if you'll consider this hacky or not. (def ^:dynamic *fn-helper*) (defn eval-at-one [f] (binding [*fn-helper* f] (eval '(*fn-helper* 1 On Wed, Aug 28, 2013 at 1:28 PM, Jamie Brandon ja...@scattered-thoughts.net javascript: wrote: You will also run into problems if your functions close over any data: user (let [f (fn [] 1)] (eval `(~f))) 1 nil user (let [x 1 f (fn [] x)] (eval `(~f))) IllegalArgumentException No matching ctor found for class user$eval38616$f__38617 clojure.lang.Reflector.invokeConstructor (Reflector.java:163) I'm struggling with this as well, I'm definitely interested in finding a non-hacky way to pass closures through eval without leaking memory. Perhaps something like: (let [x 1 f (fn [] x) f-sym (gensym)] (intern *ns* gensym (weak-ref f)) (with-meta (eval `(fn [] (do-stuff-with @~f))) {::strong-ref f})) So that way f will be freed up when the resulting fn is gced. On 28 August 2013 17:59, Ben Wolfson wol...@gmail.com javascript: wrote: On Wed, Aug 28, 2013 at 9:27 AM, Jamie Brandon ja...@scattered-thoughts.net javascript: wrote: If you aren't worried about leaking memory, a possible workaround is to intern the fn in some namespace and then put the symbol in the macro output. Hrm, I hope it doesn't come to that---as long as I'm creating the functions with their metadata, I can make things work, because I can add extra information to the with-meta call or do extra things when making the call. What I'd like, though, is for it to be possible to copy the metadata over to a new function by client code, just using the regular (with-meta (fn [blah] blah) (meta old-fn)) mechanism. But then the sneaky symbol, or whatever extra thing, in the metadata, that's used in the form to be eval-ed is pointing to the original function, not the one passed in. Maybe just providing a utility for fixing up the metadata is the right move, though it's kidn of dissatisfying. -- 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 clo...@googlegroups.comjavascript: 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 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 clojure+u...@googlegroups.com javascript:. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are
Re: [ANN] core.typed 0.2.0 - Production Ready
Excellent work. I noticed that function parameter types default to Any when not Annotated. What was the reasoning behind not mirroring this behavior for vars, and instead requiring an annotation? On Wednesday, August 28, 2013 5:28:35 PM UTC-5, Ambrose Bonnaire-Sergeant wrote: Hi, After 10 months and 26 0.1.x releases of transitioning core.typed from an ambitious student project, I am finally comfortable recommending core.typed for production use. Production Ready My interpretation of production ready in this context is: - core.typed can *find bugs* in real code - core.typed will *not slow down* your existing code by loading a large library at production. (core.typed does introduce an extra identity-like function call at type annotations, I assume this is a candidate for optimisation via HotSpot) - A basic *tutorial*, API docs and example project exist - core.typed is *currently used in production* with success (at CircleCI for several months) - The core type checking API is mostly *stable*, with only very minor removals/breaking changes in the last few months. There are several outstanding issues, but I am satisfied that core.typed can bring real utility to real programs *today* and with *no production-time drawbacks*, thus this release. How to get started Leiningen dep: [org.clojure/core.typed 0.2.0] ...; for very recent releases:repositories {sonatype-oss-public https://oss.sonatype.org/content/groups/public/} If you like following tutorials try the user/types guide. If you just want to get your hands on some typed code, see the Example project. core.typed User Guidehttps://github.com/clojure/core.typed/wiki/User-Guide core.typed Types Guide https://github.com/clojure/core.typed/wiki/Types Example project https://github.com/frenchy64/core.typed-example API Reference http://clojure.github.io/core.typed/ core.typed Github Home https://github.com/clojure/core.typed core.typed Wiki https://github.com/clojure/core.typed/wiki Please report bugs, ask questions or discuss things on the mailing listhttps://groups.google.com/forum/?fromgroups#!forum/clojure-core-typed . (FWIW I'm ambrosebs on #clojure.) Thanks, Ambrose -- -- 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: To read and write bytes via Socket
Armando, thank you for your reply. Writing single value with void write(int c) sends same 2 bytes for values larger than 127 as using void write(char[] cbuf, int off, int len) of BufferedReader http://docs.oracle.com/javase/jp/6/api/java/io/BufferedWriter.html Code: (require '[clojure.java.io :refer :all]) (with-open [s (java.net.Socket. *ip.of.test.server* *port_of_test_server *)] (let [^java.io.BufferedWriter wtr (writer s)] (doseq [i [0 1 127 128 255]] (.write wtr i)) (.flush wtr))) sends same bytes as code in my previous post. I can't find other appropriate methods of BuffererdReader, Reader and OutputStreamReader http://docs.oracle.com/javase/jp/6/api/java/io/Writer.html http://docs.oracle.com/javase/jp/6/api/java/io/OutputStreamWriter.html than void write(int c) void write(char[] cbuf) void write(char[] cbuf, int off, int len) . Does anyone have any information? Thanks in advance. Yoshinori Kohyama -- -- 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: Clojure cheatsheets with several flavors of tooltips
Hi Alex, thank you very much for updating the cheatsheet! Is it not possible to get hold of somebody who has the rights to add the JS/... necessary for the tooltips? It would be so much cooler to have them there... Regards, Jakub --- Jakub Holy Solutions Engineer | +47 966 23 666 Iterate AS | www.iterate.no The Lean Software Development Consultancy - http://theholyjava.wordpress.com/ - Den 9. aug. 2013 05:06 skrev Alex Miller a...@puredanger.com følgende: I updated the cheatsheet on clojure.org to the latest version (no tooltips). I don't have enough access to add the additional assets that would make that possible. Alex On Thursday, August 8, 2013 2:13:24 PM UTC-4, Andy Fingerhut wrote: It is relatively easy (with help from the right person with permission to update clojure.org/cheatsheet) to update the non-tooltip version of the cheatsheet there. When last they checked for me some months ago, it was less easy to enable the tooltip version of the cheatsheet at clojure.org/cheatsheet. On the plus side, the link to the other versions of the cheatsheet is now at the top of the page rather than the bottom, so it should be easier for people to find. Andy On Thu, Aug 8, 2013 at 1:46 AM, Jakub Holy jakub...@iterate.no wrote: Hi Andy, This cheatsheet of yours is wonderful! Are there any chances of getting it to clojure.org/cheatsheet? It is a shame that the cheatsheet at clojure.org is only for Clj 1.4 and doesn't have the beautiful tooltips. Thank you, Jakub On Monday, April 23, 2012 8:35:12 PM UTC+2, Andy Fingerhut wrote: The tooltip version of the Clojure/Java cheatsheet is not published at [1] just yet, but hopefully we can figure out how to make that happen in a while: [1] http://clojure.org/cheatsheet There is an updated link at the bottom of that page called Download other versions that leads to [2]: [2] http://jafingerhut.github.com Page [2] has links to 5 different variations of the cheatsheet, and I plan for it to be the long term home for where I publish cheatsheets (in addition to [1]). They differ only in whether they have tooltips, how the tooltip is implemented, and whether the tooltip includes a 1-line summary of what ClojureDocs.org contained at a recent snapshot time. It does not query ClojureDocs.org every time it displays a tooltip. That would slow down the tooltip display, and likely be too much load on ClojureDocs.org. There are also links on that page to the Github repository containing the source that generated the cheatsheets, and to the PDF versions. Note: It is free and quick to create an account on ClojureDocs.org, and you don't even need to create an account if you have an OpenID account on Google, Yahoo, or myOpenId. Just click log in in the upper right corner of [3], and you can edit examples and see alsos, too. Don't be dismayed thinking that you must write special markup to create examples. In most cases, all it takes is copying and pasting a REPL session, with some editing to add comments if it helps understanding what is going on. The color highlighting is automatically added by the web server. [3] http://clojuredocs.org Andy -- -- 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=enhttp://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/**groups/opt_outhttps://groups.google.com/groups/opt_out . -- -- 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 a topic in the Google Groups Clojure group. To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/VcXDWmUXt1I/unsubscribe. To unsubscribe from this group and all its topics, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- 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
Re: To read and write bytes via Socket
Resolved. I overlooked that OutputStream has void write(byte[] b, int off, int len) . With write(byte[] ...) of OutputStream instead of write(char[] ...) of BufferedWritersends I can send the bytes that I want to send. Code: (require '[clojure.java.io :refer :all]) (with-open [s (java.net.Socket. *ip.of.test.server* *port_of_test_server *)] (let [^java.io.OutputStream os (.getOutputStream s) ^bytes obuf (byte-array (map #(byte (if ( % 128) % (- % 256))) [0 1 127 128 255]))] (.write os obuf 0 5) (.flush os))) sent [0x00, 0x01, 0x7f, 0x80, 0xff] to my test server. Thank you, Armando and all. Regards, Yoshinori Kohyama -- -- 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.
Preferred way of binding jdbc connections
Hello, if I want to run some sql code in a transaction, I can do this (where clojure.java.jdbc is referred to as j): (j/db-transaction [conn dbspec] use conn here But if I have a function I want to call from this transaction, say to do a query, then I need to pass in the connection to that function: (defn query [conn] do query on conn...) (j/db-transaction [db dbspec] (query conn)) I am trying to decide whether I like passing in the connection to query, or whether I would rather use a binding like so: (def ^:dynamic *conn*) (defn query [] do query on *conn*...) (j/db-transaction [conn dbspec] (binding [*conn* conn] (query))) Looking at the jdbc docs, I notice that this style used to be directly supported but is now deprecated. Does that mean it's a bad idea to re-implement on top of the supported API, as my example would? Can someone explain the tradeoffs involved? Thanks, Lyn Headley -- -- 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: [ANN] core.typed 0.2.0 - Production Ready
Hi Daniel, It is unsound to assume we can pass anything to an unannotated, unchecked var. core.typed makes the user explicitly mark unchecked vars, which is also a source of unsoundness, but an explicit one. Hopefully :no-check is not ambiguous in this regard. Take this example. ;; untyped namespace (defn evil-atom-reset! [a] (reset! a :foo)) ... ;; typed namespace (defn nice-typed-fn [] (let [a (ann-form (atom 1) (Atom1 Number)) _ (evil-atom-reset! a)] (+ @a 2))) If we simply assume evil-atom-reset! is of type [Any - Any], our atom gets changed underneath us, and any type guarantees do not hold anymore. The answer to this is generating contracts to wrap about our calls to untyped vars. These should probably be driven by user annotations though. Typed Racket automatically does this via macros, which is very cool, but probably impossible in Clojure. So in general, implicitly trusting untyped code can be problematic. core.typed at least makes the user be explicit about unchecked vars so there is some chance the annotation is correct. Thanks, Ambrose On Thu, Aug 29, 2013 at 12:06 PM, Daniel doubleagen...@gmail.com wrote: Excellent work. I noticed that function parameter types default to Any when not Annotated. What was the reasoning behind not mirroring this behavior for vars, and instead requiring an annotation? On Wednesday, August 28, 2013 5:28:35 PM UTC-5, Ambrose Bonnaire-Sergeant wrote: Hi, After 10 months and 26 0.1.x releases of transitioning core.typed from an ambitious student project, I am finally comfortable recommending core.typed for production use. Production Ready My interpretation of production ready in this context is: - core.typed can *find bugs* in real code - core.typed will *not slow down* your existing code by loading a large library at production. (core.typed does introduce an extra identity-like function call at type annotations, I assume this is a candidate for optimisation via HotSpot) - A basic *tutorial*, API docs and example project exist - core.typed is *currently used in production* with success (at CircleCI for several months) - The core type checking API is mostly *stable*, with only very minor removals/breaking changes in the last few months. There are several outstanding issues, but I am satisfied that core.typed can bring real utility to real programs *today* and with *no production-time drawbacks*, thus this release. How to get started Leiningen dep: [org.clojure/core.typed 0.2.0] ...; for very recent releases:repositories {sonatype-oss-public https://oss.sonatype.org/**content/groups/public/ https://oss.sonatype.org/content/groups/public/} If you like following tutorials try the user/types guide. If you just want to get your hands on some typed code, see the Example project. core.typed User Guidehttps://github.com/clojure/core.typed/wiki/User-Guide core.typed Types Guide https://github.com/clojure/core.typed/wiki/Types Example project https://github.com/frenchy64/core.typed-example API Reference http://clojure.github.io/core.typed/ core.typed Github Home https://github.com/clojure/core.typed core.typed Wiki https://github.com/clojure/core.typed/wiki Please report bugs, ask questions or discuss things on the mailing listhttps://groups.google.com/forum/?fromgroups#!forum/clojure-core-typed . (FWIW I'm ambrosebs on #clojure.) Thanks, Ambrose -- -- 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. -- -- 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: Preferred way of binding jdbc connections
Hi Lyn, Dynamic vars for resource sharing is not a favored approach due to performance and several other reasons. This blog post explains it well: http://stuartsierra.com/2013/03/29/perils-of-dynamic-scope Shantanu On Thursday, 29 August 2013 07:21:46 UTC+5:30, Lyn Headley wrote: Hello, if I want to run some sql code in a transaction, I can do this (where clojure.java.jdbc is referred to as j): (j/db-transaction [conn dbspec] use conn here But if I have a function I want to call from this transaction, say to do a query, then I need to pass in the connection to that function: (defn query [conn] do query on conn...) (j/db-transaction [db dbspec] (query conn)) I am trying to decide whether I like passing in the connection to query, or whether I would rather use a binding like so: (def ^:dynamic *conn*) (defn query [] do query on *conn*...) (j/db-transaction [conn dbspec] (binding [*conn* conn] (query))) Looking at the jdbc docs, I notice that this style used to be directly supported but is now deprecated. Does that mean it's a bad idea to re-implement on top of the supported API, as my example would? Can someone explain the tradeoffs involved? Thanks, Lyn Headley -- -- 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.