Re: Need advice/idiom to reduce number of parameters in functions
Well, this is question many people ask. :) It is a matter of tradeoffs: - Too many arguments may be an aesthetic problem. It may also reflect a design problem; you might be able to rethink a system to simplify it. (What too many means is debatable.) - With many arguments, you may choose to combine them as a map. Then you can destructure the ones you need. Risks: you may (a) lose clarity as to what arguments are used; (b) miss out on memoization opportunities. - Having ~4 to ~6 arguments may not be as bad as you think. First, it provides clarify into what the function needs. Second, memoization is easier. In summary, it may be better than the alternatives! On Wednesday, May 13, 2015 at 9:38:43 AM UTC-4, Herwig Hochleitner wrote: In functional programming you can do a similar thing as in OOP: Define your functions as closures that can access common arguments via lexical scope. So instead of creating a context object, you create functions: (defn make-context [some context parameters] {:op1 (fn [x] ...) :op2 (fn [y] ...)}) The clojure-specific variant are protocols, e.g.: (defn make-context [some context parameters] (reify ContextProtocol (op1 [_ x] ...) (op2 [_ y] ...))) They have the advantage of better type checking + defrecords to retain visibility into those context parameters. Hope that helps -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: What does ^:internal mean?
Re: Some people don't like the native approach to private vars since anyone who wants to override it can do so anyway, so they go with a purely conventional and unenforced approach: delineate the boundaries of API vs internal using :internal or :impl and/or put the internal bits in an impl namespace. Yes. I've used this approach myself sometimes. Function metadata can also enhance documentation generation. Functions with ^:internal metadata could be treated and presented as internal API only. I don't know if codox or marginalia are customizable in this way. On Monday, May 11, 2015 at 8:35:06 PM UTC-4, Mischov wrote: To answer your question, ^:internal is shorthand meaning set the :internal key of the object's metadata to true. You can read more about metadata here http://clojure.org/metadata. On Sunday, May 10, 2015 at 2:00:10 PM UTC-5, piast...@gmail.com wrote: What does ^:internal mean in this context? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A more flexible versio of - ?
In addition to the Swiss Arrows library, I'd also suggest the shield blazoned with a green arrow on a white bend on green from the House Sarsfield of Sarsfield, a noble house from Sarsfield in the Westerlands: http://awoiaf.westeros.org/index.php/House_Sarsfield On Tuesday, May 5, 2015 at 9:37:42 AM UTC-4, Tj Gabbour wrote: I really like: https://github.com/jdevuyst/fletching-macros It's nice because you can use it with plain arrows... as little exceptions. On Tuesday, May 5, 2015 at 4:09:55 AM UTC+2, Frank Siler wrote: On May 4, 2015, at 1546, Kaiyin Zhong kindl...@gmail.com wrote: Wouldn't be nice to have something like: See also Swiss Arrows: https://github.com/rplevy/swiss-arrows Great article on “hard to Google” forms in Clojure: https://yobriefca.se/blog/2014/05/19/the-weird-and-wonderful-characters-of-clojure/ Frank` -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Deterministic macro expansion for Clojure?
Thanks! A great suggestion. I'll try it. On Friday, March 27, 2015 at 8:56:21 PM UTC-4, Ben wrote: One way you can get what you want is to give up on the auto-gensym feature of the #-terminated identifiers, and call gensym directly, enabling it to be mocked out with with-redefs. E.g. instead of: (defmacro m1 [x f] `(let [x# ~x] (~f x#))) do (defmacro m1 [x f] (let [x-sym (gensym)] `(let [~x-sym ~x] (~f ~x-sym You can then do something like (defn new-gensym [] (let [counter (atom 0)] (fn [ [extra]] (symbol (str (or extra G_) (swap! counter inc)) (with-redefs [gensym (new-gensym)] (macroexpand-1 '(m1 1 inc))) (not tested) On Fri, Mar 27, 2015 at 5:50 PM, David James david...@gmail.com javascript: wrote: I agree with this motivation behind this request, which I explain in more detail here: http://stackoverflow.com/questions/16745135/how-to-test-a-clojure-macro-that-uses-gensyms We should be able to test the behavior *and* the macroexpansion. (Most things in life are not simple either/or decisions. Don't believe people that tell you otherwise.) On Monday, March 23, 2015 at 12:58:49 PM UTC-4, Chris Ford wrote: I think it's useful to think of macros as an odd form of I/O. Just as you would separate out your templating from your domain functions, separate out your defmacro from regular functions that just happen to manipulate symbols. These functions will be easier to test. On 23 March 2015 at 16:23, Sean Corfield se...@corfield.org wrote: On Mar 22, 2015, at 7:52 PM, myguidingstar phuthuycuo...@gmail.com wrote: I wonder if there is any way to make macro expansion in Clojure deterministic. That would be useful in unit tests. I’d be very interested to understand your use case… Testing what the macro expands to seems like it is test the macro system itself, not your own code. Surely in a unit test you’d want to test the _behavior_ of the code instead? Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: 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/d/optout. -- 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/d/optout.
Re: Deterministic macro expansion for Clojure?
I agree with this motivation behind this request, which I explain in more detail here: http://stackoverflow.com/questions/16745135/how-to-test-a-clojure-macro-that-uses-gensyms We should be able to test the behavior *and* the macroexpansion. (Most things in life are not simple either/or decisions. Don't believe people that tell you otherwise.) On Monday, March 23, 2015 at 12:58:49 PM UTC-4, Chris Ford wrote: I think it's useful to think of macros as an odd form of I/O. Just as you would separate out your templating from your domain functions, separate out your defmacro from regular functions that just happen to manipulate symbols. These functions will be easier to test. On 23 March 2015 at 16:23, Sean Corfield se...@corfield.org javascript: wrote: On Mar 22, 2015, at 7:52 PM, myguidingstar phuthuycuo...@gmail.com javascript: wrote: I wonder if there is any way to make macro expansion in Clojure deterministic. That would be useful in unit tests. I’d be very interested to understand your use case… Testing what the macro expands to seems like it is test the macro system itself, not your own code. Surely in a unit test you’d want to test the _behavior_ of the code instead? Sean Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ Perfection is the enemy of the good. -- Gustave Flaubert, French realist novelist (1821-1880) -- 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 javascript: 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/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008
Thanks for your comments. I see now that I should clarify: all I really need is public access to the left and right Java methods in PTM. (So, perhaps CLJ-1008 is asking for more than I really need.) It seems to me that since Clojure's RB-Tree implementation (i.e. sorted-map = PTM), it might as well expose a Java API for root node (which it does) and branches (which is does not, currently). Is there any downside to exposing the 'right' and 'left' Java methods as public? In the near term, I'll be using data.avl. I'm glad it exists! My use case involves a non-overlapping interval map to store time series data that doesn't change very often. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008
Yes, exactly, you read my mind. (I'd also like to do this a sorted-map / PersistentTreeMap (nudge, nudge) -- all that is missing would be public 'left' and 'right' accessors. I don't necessarily need rank functionality.) On Friday, February 20, 2015 at 10:39:26 AM UTC-5, Michał Marczyk wrote: Do you mean you'd like to compress {0 :a 1 :a 2 :a 3 :a 4 :b 5 :b 6 :c 7 :c 8 :c 9 :c} to something like {[0 1 2] :a [4 5] :b [6 7 8 9] :c} while maintaining the ability to ask for the value at 0, 1, …, 9? If so, you could represent the above as {0 :a 2 :a 4 :b 5 :b 6 :c 9 :c} (notice no explicit entries for 1, 7, 8) and query for the value at 7, say, using (val (avl/nearest the-map = 7)) ;= :c (avl/nearest can be implemented for built-in sorted maps using subseq and first, in fact the test suite for data.avl has an implementation like that that it compares avl/nearest against). If you need more operations – say, data.avl-style slice-{at,key} and subrange – those could be supported with some care (mostly around the possibility that a slice, say, removes an endpoint of an interval – you may need to add the slice boundary as a replacement in that case). Cheers, Michał On 20 February 2015 at 16:15, David James david...@gmail.com javascript: wrote: Thanks for your comments. I see now that I should clarify: all I really need is public access to the left and right Java methods in PTM. (So, perhaps CLJ-1008 is asking for more than I really need.) It seems to me that since Clojure's RB-Tree implementation (i.e. sorted-map = PTM), it might as well expose a Java API for root node (which it does) and branches (which is does not, currently). Is there any downside to exposing the 'right' and 'left' Java methods as public? In the near term, I'll be using data.avl. I'm glad it exists! My use case involves a non-overlapping interval map to store time series data that doesn't change very often. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008
Andy, to take advantage of the Red-Black Tree, I'm looking for public API access to the branches. (I'm not looking for a work-around.) More discussion on this at SO: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-given-value-for-clojure-sorted-maps Thanks to both Michał Marczyk and Andy for commenting on CLJ-1008 ( http://dev.clojure.org/jira/browse/CLJ-1008). On Thursday, February 19, 2015 at 1:02:53 PM UTC-5, Andy Fingerhut wrote: I haven't checked carefully, but from at least a quick look it appears that implementing the NavigableMap and NavigableSet interfaces could be done by using the existing subseq and rsubseq functions in clojure.core? It doesn't give you access to subtree nodes directly, but perhaps it is sufficient for your purposes? Andy On Wed, Feb 18, 2015 at 6:04 PM, David James david...@gmail.com javascript: wrote: Summary: I'd like to find a public API to work with the underlying tree of a sorted-map. For example: (def t (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e 6 :f)) The underlying implementation of sorted-map uses a PersistentTreeMap, which can be accessed with `tree`: (.tree t) ;= [2 :b] I have not found a way to access the left and right branches, since calling `left` fails: (.left (.tree t)) IllegalArgumentException Can't call public method of non-public class: public clojure.lang.PersistentTreeMap$Node clojure.lang.PersistentTreeMap$BlackBranch.left() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Perhaps it would be reasonable to make such calls possible, at least from the Java API (without reflection)? CLJ-1008 (http://dev.clojure.org/jira/browse/CLJ-1008) offers one possible way to support a public API. It was created in 2012. Perhaps it could use another look. Thoughts? -- 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 javascript: 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/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008
Yes, we're on the same page here. I'm very glad Michał has done great work in this Clojure data structure space. Of course, I wouldn't mind if dozens of people agreed, but I'm more interested in the pros/cons before I try to mobilize support. So, to those reading this, I'd be interested to hear if: (a) you agree with CLJ-1008 (or some friendly amendment to it) (b) you disagree with CLJ-1008 for some principled or philosophical reason (not just because you think other things are more pressing or you wouldn't personally use a a RB-Tree API right away) (c) you think more exploration is needed Some observations and context: * I find it curious that `tree` is public but `left` and `right` are not. Perhaps this was just historical accident? * Exposing the API for PersistentTreeMaps opens up a lot of useful possibilities for derivative data structures. (This is what led me to this question.) See, for example, interval trees, in particular ones with non-overlapping intervals: http://en.wikipedia.org/wiki/Interval_tree, which could be naively implemented with a PersistentTreeMap if it had public API access. On Thursday, February 19, 2015 at 3:37:46 PM UTC-5, Andy Fingerhut wrote: David: I see why you would want that. If you want this soon, I would recommend using data.avl as suggested by Michał, or copy the parts of the sorted-set/map implementation from Clojure and implement it yourself. If you don't want it soon, you could try persuading a few dozen people to vote on CLJ-1008, and hope the Clojure developers also want this change. No guarantees there. Andy On Thu, Feb 19, 2015 at 12:18 PM, David James david...@gmail.com javascript: wrote: Andy, to take advantage of the Red-Black Tree, I'm looking for public API access to the branches. (I'm not looking for a work-around.) More discussion on this at SO: http://stackoverflow.com/questions/1981859/finding-keys-closest-to-a-given-value-for-clojure-sorted-maps Thanks to both Michał Marczyk and Andy for commenting on CLJ-1008 ( http://dev.clojure.org/jira/browse/CLJ-1008). On Thursday, February 19, 2015 at 1:02:53 PM UTC-5, Andy Fingerhut wrote: I haven't checked carefully, but from at least a quick look it appears that implementing the NavigableMap and NavigableSet interfaces could be done by using the existing subseq and rsubseq functions in clojure.core? It doesn't give you access to subtree nodes directly, but perhaps it is sufficient for your purposes? Andy On Wed, Feb 18, 2015 at 6:04 PM, David James david...@gmail.com wrote: Summary: I'd like to find a public API to work with the underlying tree of a sorted-map. For example: (def t (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e 6 :f)) The underlying implementation of sorted-map uses a PersistentTreeMap, which can be accessed with `tree`: (.tree t) ;= [2 :b] I have not found a way to access the left and right branches, since calling `left` fails: (.left (.tree t)) IllegalArgumentException Can't call public method of non-public class: public clojure.lang.PersistentTreeMap$Node clojure.lang. PersistentTreeMap$BlackBranch.left() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Perhaps it would be reasonable to make such calls possible, at least from the Java API (without reflection)? CLJ-1008 (http://dev.clojure.org/jira/browse/CLJ-1008) offers one possible way to support a public API. It was created in 2012. Perhaps it could use another look. Thoughts? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: 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/d/optout. -- You received this message because you
Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008
Summary: I'd like to find a public API to work with the underlying tree of a sorted-map. For example: (def t (sorted-map 1 :a 2 :b 3 :c 4 :d 5 :e 6 :f)) The underlying implementation of sorted-map uses a PersistentTreeMap, which can be accessed with `tree`: (.tree t) ;= [2 :b] I have not found a way to access the left and right branches, since calling `left` fails: (.left (.tree t)) IllegalArgumentException Can't call public method of non-public class: public clojure.lang.PersistentTreeMap$Node clojure.lang.PersistentTreeMap$BlackBranch.left() clojure.lang.Reflector.invokeMatchingMethod (Reflector.java:88) Perhaps it would be reasonable to make such calls possible, at least from the Java API (without reflection)? CLJ-1008 (http://dev.clojure.org/jira/browse/CLJ-1008) offers one possible way to support a public API. It was created in 2012. Perhaps it could use another look. Thoughts? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: OO Programmer trying to move to Clojure: Namespace Organization
I often group functions that operate on similar data structures together in a namespace. This isn't always clear-cut, because some functions may fit in more than one namespace. I sometimes use a (soft) convention to group functions by the first argument. Yes, this means that my Clojure projects resemble OO projects, at least in terms of what logic goes where. See what works for you. Some Clojure projects I see use fairly long files. I tend to prefer smaller files myself. In my opinion, just as a function that is too long often indicates unnecessary complexity, I think files/namespaces that are too large indicates a complicated design. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Convenient memoization with destructured arguments
Thanks for mentioning it, Rob. (I have looked at Prismatic Graph before. Putting arguments in a graph (at macro time) is a powerful idea; plumbing uses this to offer a declarative way to offer various evaluation strategies. It is nice to show off Clojure macros! In this case, it makes Clojure feel more like Haskell or other lazily-evaluated languages.) When it comes to the use case I showed above, I don't think Graph would address the core problem of memoization. Graph has a memoization function, but it does not work with a graph to track cross-function arguments, like I would need in my example above. Perhaps it could be extended to do so. Perhaps it would be easier to roll my own. I'm still interested in having a discussion about all of the questions I asked: - Have others faced [the many arguments vs one composed thing, such as a map or object] tradeoff? - How do you think about it? - How do you strike a balance, if there is one? - More pointedly, is there a way to get the best of both worlds (e.g. the composed argument style AND memoization)? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Resources don't work in uberjar
You may find value in reading this: From: http://docs.oracle.com/javase/8/docs/technotes/guides/lang/resources.html Methods in the classes Class and ClassLoader provide a location-independent way to locate resources. On Tuesday, January 27, 2015 at 9:12:23 AM UTC-5, Benjamin VanRyseghem wrote: The code can be found here: https://github.com/teamwall/teamwall/blob/develop/src/server/teamwall/api.clj#L85 Here I used to do something like `io/as-file path-to-my-file` but it failed because it’s not resolved as a file anymore when it’s jarred Good luck, Ben On Tue, Jan 27, 2015 at 2:00 PM, Dan Harbin dan.h...@gmail.com javascript: wrote: Ben, I would appreciate it if you'd show me the sample code. Thanks for your help, everyone! On Tuesday, January 27, 2015 at 6:28:59 AM UTC-6, Benjamin VanRyseghem wrote: I face something similar. The issue was that inside a jar file, a resource is not a java.io.File anymore. I could turn around using an InputStream (I was in the case I wanted to serve a resource via http-kit) If you want more info, I can point you to the code where I use it Hope it helps, Ben On Tue, Jan 27, 2015 at 5:04 AM, Dan Harbin dan.h...@gmail.com wrote: I've created a sample project at Github[1] to demonstrate the problem I'm facing with accessing a resource file when using an uberjar. Could someone point out what I'm doing wrong here? Thanks! [1]: https://github.com/RasterBurn/halp ### Given this code: ### ```clojure (ns halp.core (:require [clojure.java.io :as io]) (:gen-class)) (defn -main I don't do a whole lot ... yet. [ args] (- hi.txt io/resource io/file (io/copy *out*))) ``` ### It runs well under leiningen ### ``` ➜ halp lein run . ─▄──▄ ▌▒█───▄▀▒▌ ▌▒▒▀▄───▄▀▒▒▒▐ ───▐▄▀▒▒▄▄▄▀▒▐ ─▄▄▀▒▒▒█▒▒▄█▒▐ ───▄▀▒▒▒▀██▀▒▌ ──▐▒▒▒▄▄▄▒▀▄▒▒▌ ──▌▒▒▐▄█▀▄▀█▄▒▒▒█▒▐ ─▐▒▒▒▌██▀▀▄▌ ─▌▒▀▄██▄▒▒▒▌ ─▌▀▐▄█▄█▌▄▒▀▒▒░░▒▒▒▐ ▐▒▀▐▀▐▀▒▒▄▄▒▄▒░░▌ ▐▒▒▒▀▀▄▄▒▒▒▄▒▒░░▒▒▒▐ ─▌▒▒▀▀▀▌ ─▐▐ ──▀▄▒▄▌ ▀▄▒▒▄▄▄▀▄▀ ───▐▀▒▀▄▄▀▀▀▒▄▄▀ ──▐▀▀ ``` ### But not so much as an uberjar # ``` ➜ halp java -jar target/uberjar/halp-0.1.0-SNAPSHOT-standalone.jar Exception in thread main java.lang.IllegalArgumentException: Not a file: jar:file:/home/vagrant/code/halp/target/uberjar/halp-0.1.0-SNAPSHOT-standalone.jar!/hi.txt at clojure.java.io$fn__8588.invoke(io.clj:63) at clojure.java.io$fn__8572$G__8556__8577.invoke(io.clj:35) at clojure.java.io$file.invoke(io.clj:414) at halp.core$_main.doInvoke(core.clj:11) at clojure.lang.RestFn.invoke(RestFn.java:397) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.RestFn.applyTo(RestFn.java:132) at halp.core.main(Unknown Source) ``` -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com javascript: 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/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups
Re: Convenient memoization with destructured arguments
I just renamed the subject line since my question has nothing inherently to do with heuristic search. (That was just my particular use case.) This kind of thing can happen in any codebase where destructuring of function arguments is used. On Monday, January 26, 2015 at 12:16:04 PM UTC-5, David James wrote: Background: I'm implementing a heuristic search over a tree of possibilities. The heuristic calculation runs over a map of state. I have a large number of nested functions that support this heuristic. So, for convenience, I often pass around `state` as the first argument in these functions. Inside, I use the :keys destructuring style. Commentary: This approach is convenient; however, I feel like I've veered towards one of the pitfalls of OO programming, where this convenient composition of data hides the essence of the problem. In contrast, in other projects, I've done lots of memoization -- this is easy when all arguments are explicit. Questions: Have others faced this tradeoff? How do you think about it? How do you strike a balance, if there is one? More pointedly, is there a way to get the best of both worlds (e.g. the composed argument style AND memoization)? Possible Solution: What about writing a macro to help? It would not be hard to handle the memoization of some 'base-level' functions: (defn f1 [{:keys [a b] :as state}] :costly-calculation-of-a-b) (defn f2 [{:keys [b c] :as state}] :costly-calculation-of-b-c) However, when it comes to a chain of functions, the memoization is not apparent: (defn f3 [{:keys [x] :as state}] (+ (f1 state) (f2 state) (g x))) In order to memoize `f3`, one would need to account for not only `x` but also `a`, `b`, and `c`. This would be an improvement over memoizing the entire state. Any thoughts on this kind of solution? Has it already been done? Are there other, possibly better, ways to address this overall challenge? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Heuristic search: convenient memoization?
Background: I'm implementing a heuristic search over a tree of possibilities. The heuristic calculation runs over a map of state. I have a large number of nested functions that support this heuristic. So, for convenience, I often pass around `state` as the first argument in these functions. Inside, I use the :keys destructuring style. Commentary: This approach is convenient; however, I feel like I've veered towards one of the pitfalls of OO programming, where this convenient composition of data hides the essence of the problem. In contrast, in other projects, I've done lots of memoization -- this is easy when all arguments are explicit. Questions: Have others faced this tradeoff? How do you think about it? How do you strike a balance, if there is one? More pointedly, is there a way to get the best of both worlds (e.g. the composed argument style AND memoization)? Possible Solution: What about writing a macro to help? It would not be hard to handle the memoization of some 'base-level' functions: (defn f1 [{:keys [a b] :as state}] :costly-calculation-of-a-b) (defn f2 [{:keys [b c] :as state}] :costly-calculation-of-b-c) However, when it comes to a chain of functions, the memoization is not apparent: (defn f3 [{:keys [x] :as state}] (+ (f1 state) (f2 state) (g x))) In order to memoize `f3`, one would need to account for not only `x` but also `a`, `b`, and `c`. This would be an improvement over memoizing the entire state. Any thoughts on this kind of solution? Has it already been done? Are there other, possibly better, ways to address this overall challenge? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: A (foolish) plan to re-invent IO on top of core.async
In case you are interested in a recent example, I wrote an NIO.2 based Riak client in Clojure without Netty. https://github.com/bluemont/kria It uses callback functions, so the consumer can do whatever they want; such as core.async. I agree with Timothy, above. My take-away from the experience is that core.async does not need to be *baked into* a library. It is better if it is not; for testing the library, I use atoms: https://github.com/bluemont/kria/blob/master/test/kria/test_helpers.clj#L45 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Compiling gen-class runs static initializers: workarounds, solutions?
I have a problem when compiling while using gen-class with static initializers. I use gen-class to extend a JavaFX 8 class, javafx.scene.control.Control. During compilation, a static initializer is run, raising an exception saying that the JavaFX toolkit has not been initialized. I'm going to share what I've read, since this issue seems to pop up from time to time, and see if there are better solutions than currently posted online. Here are my questions and comments: - Is there a way to run code during compilation that fires before the static initializers? I could use this as a workaround to initialize the toolkit. - Is there a way to stop the static initializers from being run? This would solve the problem. - More broadly, is is necessary for gen-class to run the static initializers during compilation? I recently read over CLJ-1315: Problem: When classes are imported in Clojure, the class is loaded using Class.forName(), which causes its static initialisers to be executed. This differs from Java where compilation does not cause classes to be loaded. I wonder if a similar approach should be used with Clojure's gen-class. Related discussions: - JIRA: CLJ-1315 http://dev.clojure.org/jira/browse/CLJ-1315 - Compilation question - why initialize classes when loading for compilation? https://groups.google.com/forum/#!searchin/clojure/static$20initializers/clojure/Qd9KTKwqsOA/OigoOrcmoAkJ - Stack Overflow: How can a static initializer be defined using gen-class http://stackoverflow.com/questions/11783736/how-can-a-static-initializer-be-defined-using-gen-class - Stack Overflow: Clojure can't import JavaFX classes with static initializers http://stackoverflow.com/questions/23365409/clojure-cant-import-javafx-classes-with-static-initializers 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/d/optout.
Using dev/user.clj breaks java compilation
I noticed this issue which I'm currently facing: https://github.com/technomancy/leiningen/issues/1477 Technomancy commented in the issue: This appears to be a bug in Clojure causing an incorrect error message that's masking the actual issue. What's happening here is that the javac task is invoking some Clojure code which performs the Java compilation, but before this code runs, Clojure runs user.clj first. (Leiningen doesn't have any control over this.) Since this contains a call to a file that imports TestClass, you've created a circular dependency. I don't know why you get this error message; it seems to be an issue with Clojure itself. Do others agree that this is an issue with Clojure itself? I haven't seen any tickets in JIRA pertaining to this. Did I overlook one? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Questions about Clojure 1.7 Release / Process / Helping Out
I'm curious about the future Clojure 1.7 release. I recently looked over these pages: - Clojure JIRA Workflow http://dev.clojure.org/display/community/JIRA+workflow - Contributing to Clojure http://dev.clojure.org/display/community/Contributing - Next Release Planning http://dev.clojure.org/display/design/Release.Next+Planning - Clojure Changelog https://github.com/clojure/clojure/blob/master/changes.md - Screening Tickets http://dev.clojure.org/display/community/Screening+Tickets - JIRA Road Map http://dev.clojure.org/jira/browse/CLJ#selectedTab=com.atlassian.jira.plugin.system.project%3Aroadmap-panel (currently showing that 54 of 73 issues have been resolved) My questions are: (Please let me know if I've overlooked links to read.) - Does Rich or Clojure Core have rough dates in mind for the 1.7 release? Any idea? (I wouldn't be surprised at all if dates were not at all a driving factor.) From what I can tell, bug fixes, a fixed set of new features, performance, and stability are the driving factors. - Do the above links about cover it and/or are there additional suggestions where community help is most needed? - Is there a good I want to help, what do I do next? page? I see that http://clojure.org/contributing has some suggestions; namely, using the mailing list. Also, the Screening Tickets link above is a great example. - An idea: I suspect there may be value for a link or blurb (from the Clojure home page) that would focus attention onto one or two hot issues each week. I say this because JIRA does not seem to be geared towards driving a critical mass to one ticket at a time -- but sometimes this is a great way to get the eyes you need on an issue. - Clojure 1.7 is alpha now. I'm curious: how much feedback does our BDFL like/need to move across the various stages (alpha, beta, release candidate, release)? - Just for fun, if we were to make a data-driven prediction on the next release, what parts of JIRA do you think are most important to consider? This is probably the best summary I've seen so far: Clojure JIRA Clojure Text Board for Release 1.7 http://dev.clojure.org/jira/secure/TaskBoard.jspa?selectedBoardId=pageType=ChartBoardsubType=ArchiveChartBoardtype=ACBselectedProjectId=10010colPage=1 . P.S. I'm building a useful list of terms/acronyms: - BDFL: Benevolent Dictator For Live (a.k.a Rich) - JIRA: We originally used Bugzilla for bug tracking and the developers in the office started calling it by the Japanese name for Godzilla, Gojira ... then it became an issue tracker, the name stuck, but the Go got dropped - hence JIRA! ... Further investigation into the name has revealed that Gorira is Japanese for gorilla, whilst Kujira is Japanese for whale. So Gojira is roughly translated to mean *gorilla the size of a whale* (from What does JIRA mean? https://confluence.atlassian.com/pages/viewpage.action?pageId=223219957 ) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Questions about Clojure 1.7 Release / Process / Helping Out
Andy and Alex: Thanks for the answers! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ANN: ClojureScript 0.0-2411
Thanks. Problem solved. On Saturday, December 6, 2014 5:34:53 AM UTC-5, David Nolen wrote: That's an issue with core.async. Make sure you have the latest. If you do, please file an issue for core.async. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: ANN: ClojureScript 0.0-2411
I'm getting the following warnings from `lein cljsbuild auto`. Anybody else? WARNING: Use of undeclared Var cljs.core.async/do-alts at line 62 file:/Users/david/.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async/impl/ioc_helpers.cljs WARNING: Bad method signature in protocol implementation, impl/Handler does not declare method called lock-id at line 719 file:/Users/david/.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at line 722 file:/Users/david/.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs WARNING: Bad method signature in protocol implementation, impl/Handler does not declare method called lock-id at line 719 /Users/david/dev/hft/target/cljsbuild-compiler-0/cljs/core/async.cljs WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at line 722 /Users/david/dev/hft/target/cljsbuild-compiler-0/cljs/core/async.cljs -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Where did the chunked sequence presentations go?
+1. I can't find these online. On Saturday, June 8, 2013 9:43:26 AM UTC-4, David Williams wrote: Hi all, I'm interested in Rich Hickey's chunked sequence presentation but both the video and the pdf seem to have been taken down. What happened to those and where can I hear a good discussion of chunked sequences? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Remote function calls / simple distributed computation
What are the ways to do remote function calls with Clojure? Here is a *low-level list* I have so far: * Java Remote Method Invocation API: http://docs.oracle.com/javase/7/docs/technotes/guides/rmi/index.html * nREPL: https://github.com/clojure/tools.nrepl There are *higher-level tools*, too, such as: * Slacker https://github.com/sunng87/slacker What else should I add to the lists? Here is my goal. I'm exploring various ways to do distributed computation. Many distributed computation platforms (e.g. Storm, Hadoop) require (1) significant dev-ops setup (2) deployment via a JAR file (3) quite a bit of time lag to get things started. I was hoping to find lighter-weight, more responsive, ways to do distributed computation. I also consider this a learning exercise. I like PigPen's use of a custom `pmap` function to distributes work: https://github.com/Netflix/PigPen (But it requires Pig and Hadoop) It could be nifty to have a `pmap` that worked, say, over a set of machines connected via nREPL. Has this already been done? Thanks! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ANN] Kria, an async driver for Riak 2
I started Kria in January I think. It has tests, and I use in for (currently small) but real projects. It works great so far for me. I'd appreciate it if you try it out. On Fri, Mar 7, 2014 at 9:24 PM, dgrnbrg dsg123456...@gmail.com wrote: This is really exciting! One question I have is how mature is Kria? Given that riak 2 isn't yet out, I'm still curious as to what kinds of testing/burn in you've done? -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[ANN] Kria, an async driver for Riak 2
Kria (a right rotation of Riak) is an asynchronous Clojure driver for Riak 2.0 built on top of Java 7's NIO.2. It uses Riak's protocol buffer interface. https://github.com/bluemont/kria https://clojars.org/kria In my work projects, we have found that core.async works great as a layer on top of Kria. Just create a core.async channel in advance and have the callback put the desired return value in the core.async channel. (You might also try atoms or promises.) There are several Riak drivers in Clojure, and I hope some people find this one useful. I have a section in the README about why I made it. Feedback welcome! It does not yet support all of the Riak API, but the essentials are there. -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/d/optout.
Re: Possible heisenbug in test suite (not in individual test runs) with memoization
Justin and Cedric: thank you for your suggestions. I removed all uses of `with-precision`; instead, I used various BigDecimal methods directly, such as .divide, .round, and .setScale by passing in a MathContext. Best I can tell (so far), this solved my problem. On Monday, January 6, 2014 9:19:50 PM UTC-5, Cedric Greevey wrote: It's possibly an interaction between memoization and dynamic vars; more specifically, a result might be being memoized with one with-precision context active, and then recalled with a different one active, with arguments that compare equal despite the different precisions (say, because those arguments that are BigDecimals are exactly representable at the lower of the two precisions). If the result is *not* the same at the higher precision, that could cause an expected-equal check to fail in your test. I'd also wonder at possibly having a test work if it used a memoized result generated earlier with a finite precision in effect, and fail with ArithmeticException without the memoization if the test doesn't set a precision limit itself and the result's not exactly representable at any finite precision (e.g. 1/7); but this would likely result in a test that worked in the suite and failed in isolation, instead of the reverse. However, if high memory use is causing a memoized value computed at limited precision to be forgotten and then recalculated with no precision limit, that might trigger failures in the suite of tests that worked in isolation. In any event, subtle interaction of with-precision's underlying dynamic var *math-context* with memoization is an obvious suspect worth investigating, even if it might ultimately be acquitted by the jury. :) On Mon, Jan 6, 2014 at 1:21 PM, Justin Kramer jkkr...@gmail.comjavascript: wrote: Shot in the dark: check that arguments passed to your memoized functions use consistent typing. A BigDecimal such as 1M does not necessarily equal 1 (a Long): (= 1 1M) false (== 1 1M) true Your memoized functions could be recomputing values unnecessarily if you're giving them different types of numbers. Justin On Monday, January 6, 2014 12:57:49 PM UTC-5, David James wrote: I've got a Clojure test suite that fails when run as whole but passes when run piecemeal. This just started happening. I've tested the code thoroughly. The bug pops up in a part of the code that I did not change. So, at present, it feels like a heisenbug! These may be some relevant pieces: * I'm using memoization; the failures happen in memoized functions. * I'm doing a lot of various precision BigDecimal math. Some tentative guesses: * Somehow one test is affecting another test Questions (there are speculative): * What are some possible ways that memoization might fail (e.g. return an incorrect value)? * Is it possible that higher memory usage could cause memoization results to get lost? Unfortunately, it is a sizable code base, and I don't have a small, reproducible example. Any suggestions? -David -- -- 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.
Possible heisenbug in test suite (not in individual test runs) with memoization
I've got a Clojure test suite that fails when run as whole but passes when run piecemeal. This just started happening. I've tested the code thoroughly. The bug pops up in a part of the code that I did not change. So, at present, it feels like a heisenbug! These may be some relevant pieces: * I'm using memoization; the failures happen in memoized functions. * I'm doing a lot of various precision BigDecimal math. Some tentative guesses: * Somehow one test is affecting another test Questions (there are speculative): * What are some possible ways that memoization might fail (e.g. return an incorrect value)? * Is it possible that higher memory usage could cause memoization results to get lost? Unfortunately, it is a sizable code base, and I don't have a small, reproducible example. Any suggestions? -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.
[ANN] Example async TCP echo client/server using Java 7 NIO.2.
An asynchrononous TCP echo client/server in Clojure using Java 7 NIO.2. https://github.com/bluemont/clj-async-tcp-echo-nio.2 As I've been diving into async libraries in Java and Clojure, I thought it would be nice to make a simple example with the Java 7 NIO.2 async classes. I'm sure there is room for improvement, so please let me know if you have feedback or suggestions. I find this Clojure version easier to follow than existing Java examples, largely because `proxy` makes the callbacks more compact. I intentionally kept the callbacks at the top-level, thus avoiding a lot of nesting, which led to some minor callback hell. The scoping is clearer that way, even if the program flow is not. I would expect that different people would have different preferences. I would be interested to see other ways of handling it (like core.async, perhaps?). -- David James http://bluemontlabs.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.
Auto-reloading static HTML resource with Enlive + Pedestal
I took a stab at trying to answer this but hit a wall. http://stackoverflow.com/questions/20108899/enlive-template-auto-reload-detect-changes-in-a-pedestal-service/20447481#20447481 What are we missing? 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.
Re: Feedback on destructuring code walkthrough? (could not nest :keys inside :keys)
Thanks Karsten! I updated the Github example based on your recommendation. On Friday, November 22, 2013 4:30:19 PM UTC-5, Karsten Schmidt wrote: The nested `:keys` form for `b1`/`b2` must be moved out from the vector containing `a`... (defn foo [{:keys [a] {:keys [b1 b2] :as b} :b}] [a b1 b2 b]) (foo {:a 1 :b {:b1 2 :b2 3}}) ; = [1 2 3 {:b2 3, :b1 2}] On 22 November 2013 19:06, David James david...@gmail.com javascript: wrote: I made a quick destructuring code walkthrough at https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.cljhttps://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fxpe%2Fclj-destruct%2Fblob%2Fmaster%2Fsrc%2Fdestruct%2Fcore.cljsa=Dsntz=1usg=AFQjCNEaJlE7Upr04MpIdQ-pEUcrLbbZkg I was hoping to show how to nest :keys inside of :keys but failed. Did I overlook something? -- -- 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.
Feedback on destructuring code walkthrough? (could not nest :keys inside :keys)
I made a quick destructuring code walkthrough at https://github.com/xpe/clj-destruct/blob/master/src/destruct/core.clj I was hoping to show how to nest :keys inside of :keys but failed. Did I overlook something? -- -- 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: Debugging a custom reader literal for a sorted-map
Should I file a bug report at this point? (Correcting the email title.) On Fri, Aug 9, 2013 at 3:04 AM, Jozef Wagner jozef.wag...@gmail.com wrote: This ticket may be related, http://dev.clojure.org/jira/browse/CLJ-1093 On Friday, August 9, 2013 12:08:06 AM UTC+2, Jozef Wagner wrote: It may be a bug somewhere in a Compiler. I've lost track at https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L6624 after debugging this: user (def x `(quote ~(list 1 (clojure.lang.PersistentTreeMap/create (seq [1 2 3 4]) #'user/x user x (quote (1 #sorted-map (1 2 3 4))) user (.eval (clojure.lang.Compiler/analyze clojure.lang.Compiler$C/EXPRESSION x)) (1 #sorted-map (1 2 3 4)) user (eval x) (1 {1 2, 3 4}) JW On Thursday, August 8, 2013 10:14:57 PM UTC+2, David James wrote: I'd really appreciate if others could take a look. I wonder if it may be a Clojure reader bug. On Thu, Aug 8, 2013 at 3:55 PM, Jozef Wagner jozef@gmail.com wrote: It seems there is something else in data reader which causes this change. user= (class '#foo/sm (1 2 3 4)) clojure.lang.PersistentArrayMap user= (class (read-string #foo/sm (1 2 3 4))) clojure.lang.PersistentTreeMap It's quite puzzling. In both cases the evaluation does not take place, but still the transition to PersistentArrayMap occurs. JW On Thursday, August 8, 2013 9:49:24 PM UTC+2, David James wrote: That's a good point about: user= eval (to-sorted-map '(1 2 3 4))) {1 2, 3 4} But this should work, right? user= (assoc #sorted-map (:a 1 :b 2) :c 3) {:c 3, :a 1, :b 2} ; incorrect -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/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.
Debugging a custom reader literal for a sorted-set
I am having trouble with an implementation of a custom reader literal called #sorted-set. Please see my short code first: https://github.com/xpe/sorted-map-literal Why does this work correctly: (to-sorted-map '(1 2 3 4)) #sorted-map (1 2 3 4) ; correct While this does not? #sorted-map (1 2 3 4) {1 2, 3 4} ; incorrect Thanks, David P.S. BTW, I understand that I should not release non-namespaced reader literals; this is just a self-contained experiment. -- -- 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: Debugging a custom reader literal for a sorted-set
That's a good point about: user= eval (to-sorted-map '(1 2 3 4))) {1 2, 3 4} But this should work, right? user= (assoc #sorted-map (:a 1 :b 2) :c 3) {:c 3, :a 1, :b 2} ; incorrect -- -- 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: Debugging a custom reader literal for a sorted-set
I'd really appreciate if others could take a look. I wonder if it may be a Clojure reader bug. On Thu, Aug 8, 2013 at 3:55 PM, Jozef Wagner jozef.wag...@gmail.com wrote: It seems there is something else in data reader which causes this change. user= (class '#foo/sm (1 2 3 4)) clojure.lang.PersistentArrayMap user= (class (read-string #foo/sm (1 2 3 4))) clojure.lang.PersistentTreeMap It's quite puzzling. In both cases the evaluation does not take place, but still the transition to PersistentArrayMap occurs. JW On Thursday, August 8, 2013 9:49:24 PM UTC+2, David James wrote: That's a good point about: user= eval (to-sorted-map '(1 2 3 4))) {1 2, 3 4} But this should work, right? user= (assoc #sorted-map (:a 1 :b 2) :c 3) {:c 3, :a 1, :b 2} ; incorrect -- -- 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.
Suggestion: add `into` on clojure.org/data_structures page
I noticed that `into` is not currently mentioned on http://clojure.org/data_structures How do community-suggested documentation changes work? Is there a wiki? Auto-generated docs from source? 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