Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
On Monday, December 8, 2014 2:26:42 AM UTC-5, Andy Fingerhut wrote: In regards to your question Why isn't this documented anywhere?, it is documented somewhere -- in the documentation string for clojure.edn/read, the very function you were attempting to use: user= (doc clojure.edn/read) - clojure.edn/read ([] [stream] [opts stream]) Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in*. What's *not* documented is that io/reader doesn't output something that edn/read can use directly, nor is there documented an officially recommended workaround for this. AFAICT just wrapping the reader output in (java.io.PushbackReader. ...) works. Still, this is awkward, verbose, and prevents the (nontrivial) use of edn in a platform-neutral way by referring only to Clojure functions without direct interop. Well, except for the even more awkward workaround of slurp and read-string, with the accompanying need to hold the entire file in memory *twice* for a short time. As far as why it requires a PushbackReader, I didn't design the API. Yes, some things in Clojure require using Java interop, and in many (but not all) cases, file I/O requires it. Perhaps io/reader should output a PushbackReader, if only for convenience's sake. Also, how does this work on ClojureCLR or ClojureScript? Neither of those platforms has a java.io.PushbackReader, and I'm not even sure what the equivalent of the clojure.java.io namespace is for them, unless the java in that name is misleading. -- 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: test.check generating hierarchy with relations
I haven't touched test.check yet, si this might be completely off the mark, but based on my limited understanding, here's what I think happens. for-all probably removes one level of nesting from your generator, which means that bindings is bound to a seq with one element, which is a map. Then, keys in the (let [ks (into #{} (keys bindings))]... Form turns its argument into a seq, which is easy as it is already one, and then tries to map the key function on the result. The key function expects a Map.Entry, but here the elements of the seq are (or actually is, as there is only one) maps, so it blows up. Easiest way to test (I'm on my phone, emse I'd have done it) this hypothesis would be to turn the into for into (into #{} (keys (first bindings))). Once confirmed, I would suggest getting ris of that extra level of nesting earlier, for example inside your -maps fn (mapcat identity should do the trick). On Monday, 8 December 2014, cig clifford.goldb...@gmail.com wrote: Hi I would like to test a function which recursively traverses the nodes in a graph and collects them. For example, (def graph {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]} my function is given a starting point say, 1 and should then traverse each node which is reachable and return the set. In this case the result should be: #{3, 4, 5, 7, 8, 9} note: it does not return any elements reachable by 10. I would like to test this using test.check, but I would like to generate test data which will exercise the traversal of the graph. I found a similar thread here: https://groups.google.com/forum/#!topic/clojure/YWeT8BFc8k4 But, I don't think the proposed solution would suit this use case. So, I tried generating a graph with relations using core.logic (defn -maps take the output of run* and convert it into sequence of maps [q] (let [r (- q (partition 2) (map (fn [[k v]] {k (apply vector v)})) (apply merge))] r )) (defn gen-hierarchy generate a related hierarchy [size] (let [vars1 (- (repeatedly 7 lvar) (into [])) vars2 (- (repeatedly 7 lvar) (into [])) vars3 (- (repeatedly 7 lvar) (into []))] (- (run size [q] (fresh [?k1 ?k2 ?k3 ?v1 ?v2 ?v3 ?a] (fd/distinct vars1) (everyg #(fd/in % (fd/interval 1 9)) vars1) (fd/in ?k1 (fd/interval 1 9)) (rembero ?k1 vars1 ?v1) (membero ?k2 ?v1) (fd/distinct vars2) (everyg #(fd/in % (fd/interval 1 9)) vars2) (rembero ?k2 vars2 ?v2) (membero ?k3 ?v2) (fd/distinct vars3) (everyg #(fd/in % (fd/interval 1 9)) vars3) (rembero ?k3 vars3 ?v3) (appendo [?k1 ?v1] [?k2 ?v2] ?a) (appendo ?a [?k3 ?v3] q))) (map -maps Hooking this into test.check. I tried the following: (defn gen-port-hierarchy [] (gen/sized (fn [size] (gen/fmap #(gen-hierarchy %) (gen/return size) (gen/sample (gen/not-empty (gen-port-hierarchy)) 1) Which does produce more or less what I'm after: (({6 [2 3 4 5 7 1], 3 [6 7 1 2 4 5], 1 [3 2 4 5 6 7]}) ({5 [1 2 3 4 6 7], 7 [5 3 4 6 1 2], 1 [7 2 3 4 5 6]})) However, when I try use this in a spec: (prop/for-all [bindings (gen/not-empty (gen-port-hierarchy))] (let [ ks (into #{} (keys bindings))] ...) I seem to be getting back a LazySeq which then leads to a ClassCastException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry Am I on the completely wrong path here? Or have I incorrectly hooked this generator up with test.check? Any help would be very appreciated. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be
Re: Open html file in Clojure
This seems to be what Fluid is talking about: https://docs.oracle.com/javase/tutorial/uiswing/components/html.html I wiuld be a bit wary, however: I doubt this is a complete implementation of an HTML5-compatible browser with state of the art JavaScript interpreter. It's worth trying, but I would not really bet on that being able to display a Google Maps widget. On Monday, 8 December 2014, Fluid Dynamics a2093...@trbvm.com wrote: On Sunday, December 7, 2014 6:50:54 PM UTC-5, juan.facorro wrote: Hi Priyanka, I don't think there's enough information for someone to be able to help you. When you say .html do you mean JavaScript or ClojureScript code? It will be a lot easier to help you, if you share the code from the desktop app and the code you are using to get the location information. It sounds like he just wants to display a web page in his app, and has its URL. I think there may be Java Swing components that can do that. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: For review: Clojure Namespace Isolation
Thank you. I have signed the contributor agreement and applied to join clojure-dev (request pending). On Monday, December 8, 2014 3:38:15 AM UTC+8, Alan Forrester wrote: On 7 December 2014 at 19:27, Fluid Dynamics a209...@trbvm.com javascript: wrote: On Sunday, December 7, 2014 11:12:37 AM UTC-5, Bozhidar Batsov wrote: I think you should post this to cloju...@googlegroups.com To where? Your post displayed like that, and I couldn't get a usable tooltip expanding the address by mousing over it either. clojure slash dev at googlegroups dot com with no spaces and with @ and - in place of slash and at. Alan -- 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: For review: Clojure Namespace Isolation
Naive question: does that solve the dependency problem where two explicit dependencies depend on different versions of a transitive one and something breaks because of it? On Monday, 8 December 2014, Ralph Ritoch rrit...@gmail.com wrote: Thank you. I have signed the contributor agreement and applied to join clojure-dev (request pending). On Monday, December 8, 2014 3:38:15 AM UTC+8, Alan Forrester wrote: On 7 December 2014 at 19:27, Fluid Dynamics a209...@trbvm.com wrote: On Sunday, December 7, 2014 11:12:37 AM UTC-5, Bozhidar Batsov wrote: I think you should post this to cloju...@googlegroups.com To where? Your post displayed like that, and I couldn't get a usable tooltip expanding the address by mousing over it either. clojure slash dev at googlegroups dot com with no spaces and with @ and - in place of slash and at. Alan -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: For review: Clojure Namespace Isolation
Gary, What your stating is possible with this, but it wouldn't be automatic. You could load the one dependency in one isolation, and load the second dependency in a second isolation. This is where a bit of hard work would be needed to keep the pointers returned when you create the two environments, Go into each environment to grab pointers to the namespace(s) you depend on. Then you need to create your own instance of a namespace container (clojure.lang.NamespaceContainer.) which gives you the capability of calling it's putIfAbsent method to import object references of those namespaces from the two environments. This was not an intended feature, but it is a feature that can be accessed. Best Regards, Ralph Ritoch On Monday, December 8, 2014 8:39:29 PM UTC+8, Gary Verhaegen wrote: Naive question: does that solve the dependency problem where two explicit dependencies depend on different versions of a transitive one and something breaks because of it? On Monday, 8 December 2014, Ralph Ritoch rri...@gmail.com javascript: wrote: Thank you. I have signed the contributor agreement and applied to join clojure-dev (request pending). On Monday, December 8, 2014 3:38:15 AM UTC+8, Alan Forrester wrote: On 7 December 2014 at 19:27, Fluid Dynamics a209...@trbvm.com wrote: On Sunday, December 7, 2014 11:12:37 AM UTC-5, Bozhidar Batsov wrote: I think you should post this to cloju...@googlegroups.com To where? Your post displayed like that, and I couldn't get a usable tooltip expanding the address by mousing over it either. clojure slash dev at googlegroups dot com with no spaces and with @ and - in place of slash and at. Alan -- 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.
Re: For review: Clojure Namespace Isolation
Gary, One additional note. When your about to use a dependency you will still need to enter into the isolation of that dependency for any feature that accesses namespaces not in your current environment (such as any call to the dependency which uses conflicting namespaces). Not every feature of a dependency will require the conflicting dependencies, but some will. It wouldn't be easy, or automatic, but it would become possible. Best Regards, Ralph Ritoch On Monday, December 8, 2014 9:23:12 PM UTC+8, Ralph Ritoch wrote: Gary, What your stating is possible with this, but it wouldn't be automatic. You could load the one dependency in one isolation, and load the second dependency in a second isolation. This is where a bit of hard work would be needed to keep the pointers returned when you create the two environments, Go into each environment to grab pointers to the namespace(s) you depend on. Then you need to create your own instance of a namespace container (clojure.lang.NamespaceContainer.) which gives you the capability of calling it's putIfAbsent method to import object references of those namespaces from the two environments. This was not an intended feature, but it is a feature that can be accessed. Best Regards, Ralph Ritoch On Monday, December 8, 2014 8:39:29 PM UTC+8, Gary Verhaegen wrote: Naive question: does that solve the dependency problem where two explicit dependencies depend on different versions of a transitive one and something breaks because of it? On Monday, 8 December 2014, Ralph Ritoch rri...@gmail.com wrote: Thank you. I have signed the contributor agreement and applied to join clojure-dev (request pending). On Monday, December 8, 2014 3:38:15 AM UTC+8, Alan Forrester wrote: On 7 December 2014 at 19:27, Fluid Dynamics a209...@trbvm.com wrote: On Sunday, December 7, 2014 11:12:37 AM UTC-5, Bozhidar Batsov wrote: I think you should post this to cloju...@googlegroups.com To where? Your post displayed like that, and I couldn't get a usable tooltip expanding the address by mousing over it either. clojure slash dev at googlegroups dot com with no spaces and with @ and - in place of slash and at. Alan -- 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.
Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
Nothing in the Java.io namespace was made by the clojure team, so it's not their fault that reader and pushbackreader aren't cross compatible. I'm assuming that they need something from pushbackreader for performance reasons, but that's just a guess. Clojurescript and ClojureCLR must have different solutions because they're just different platforms. Abstracting the whole high performance IO api from each of these platforms is silly and probably unwise. --Ashton Sent from my iPhone On Dec 8, 2014, at 1:12 AM, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 2:26:42 AM UTC-5, Andy Fingerhut wrote: In regards to your question Why isn't this documented anywhere?, it is documented somewhere -- in the documentation string for clojure.edn/read, the very function you were attempting to use: user= (doc clojure.edn/read) - clojure.edn/read ([] [stream] [opts stream]) Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in*. What's *not* documented is that io/reader doesn't output something that edn/read can use directly, nor is there documented an officially recommended workaround for this. AFAICT just wrapping the reader output in (java.io.PushbackReader. ...) works. Still, this is awkward, verbose, and prevents the (nontrivial) use of edn in a platform-neutral way by referring only to Clojure functions without direct interop. Well, except for the even more awkward workaround of slurp and read-string, with the accompanying need to hold the entire file in memory *twice* for a short time. As far as why it requires a PushbackReader, I didn't design the API. Yes, some things in Clojure require using Java interop, and in many (but not all) cases, file I/O requires it. Perhaps io/reader should output a PushbackReader, if only for convenience's sake. Also, how does this work on ClojureCLR or ClojureScript? Neither of those platforms has a java.io.PushbackReader, and I'm not even sure what the equivalent of the clojure.java.io namespace is for them, unless the java in that name is misleading. -- 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.
Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
2014-12-08 8:12 GMT+00:00 Fluid Dynamics a2093...@trbvm.com: On Monday, December 8, 2014 2:26:42 AM UTC-5, Andy Fingerhut wrote: In regards to your question Why isn't this documented anywhere?, it is documented somewhere -- in the documentation string for clojure.edn/read, the very function you were attempting to use: user= (doc clojure.edn/read) - clojure.edn/read ([] [stream] [opts stream]) Reads the next object from stream, which must be an instance of java.io.PushbackReader or some derivee. stream defaults to the current value of *in*. What's *not* documented is that io/reader doesn't output something that edn/read can use directly, nor is there documented an officially recommended workaround for this. FWIW I don't think that io/reader(v1.2) was intended to output something that edn/read can use directly, as it was added well before clojure.edn (v1.5). AFAICT just wrapping the reader output in (java.io.PushbackReader. ...) works. There you go. Still, this is awkward, verbose, and prevents the (nontrivial) use of edn in a platform-neutral way by referring only to Clojure functions without direct interop. Well, except for the even more awkward workaround of slurp and read-string, with the accompanying need to hold the entire file in memory *twice* for a short time. As far as why it requires a PushbackReader, I didn't design the API. Yes, some things in Clojure require using Java interop, and in many (but not all) cases, file I/O requires it. Perhaps io/reader should output a PushbackReader, if only for convenience's sake. io/reader is not meant to be used solely as an input to edn/read. Also, how does this work on ClojureCLR or ClojureScript? Neither of those platforms has a java.io.PushbackReader, and I'm not even sure what the equivalent of the clojure.java.io namespace is for them, unless the java in that name is misleading. Exactly! There is no clojure.java.io as they are on a different host. Different host implies likely different I/O capabilities. BTW cljs has cljs.reader/read-string -- 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. -- László Török -- 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: For review: Clojure Namespace Isolation
One important piece of information about this feature is that it doesn't manipulate classloaders. This feature was designed to be used with OSGi or applications that handle their own classloading issues. In a typical application when entering a namespace isolation you may also need to bind a separate Compiler/LOADER and Thread context loader, but those classloaders can, and should, have common parent classloaders to load clojure from the same classloader. This feature simply isolates clojure namespaces, it doesn't manipulate the underlying Java support systems which can already be manipulated with existing clojure features. The benefit of this feature is that you can create separate namespace environments with different copies of the same namespace names without needing to run separate run-times making it possible for them to directly share all clojure data types via shared namespaces since they're loaded by the same classloader. A side effect of the implementation is that it is possible to copy namespaces from one environment to another if you have the pointer returned from creating the environment. I have considered adding automatic creation of dynamic classloaders and associating them with isolation environments but that can be done from libraries using existing clojure features. For future reference since additional features will likely be added to this fork, this feature is implemented via the git commit https://github.com/rritoch/clojure/commit/0f4804bbf584049fd85ffa872f10522cc41eff9a -- 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.
Ring and Compojure in Clojurescript
Hi guys, I love making Clojure web apps, however their startup time is a serious drawback when used with a transient hosting service such as Heroku. My thought is to port Ring and Compojure over to Clojurescript and create a Node.js ring adapter. Has anybody tried something like this? Any suggestions? Matt -- 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.
Ring and Compojure with Node.js via Clojurescript
Dear Community, I love making Clojure web apps, however their startup time is a serious drawback when used with a transient hosting service such as Heroku. My thought is to port Ring and Compojure over to Clojurescript so that can get their nice abstractions hosted on the Node.js runtime. Any thoughts or suggestions? Matthew -- 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: For review: Clojure Namespace Isolation
Thanks for these clarifications! On Monday, 8 December 2014, Ralph Ritoch rrit...@gmail.com wrote: One important piece of information about this feature is that it doesn't manipulate classloaders. This feature was designed to be used with OSGi or applications that handle their own classloading issues. In a typical application when entering a namespace isolation you may also need to bind a separate Compiler/LOADER and Thread context loader, but those classloaders can, and should, have common parent classloaders to load clojure from the same classloader. This feature simply isolates clojure namespaces, it doesn't manipulate the underlying Java support systems which can already be manipulated with existing clojure features. The benefit of this feature is that you can create separate namespace environments with different copies of the same namespace names without needing to run separate run-times making it possible for them to directly share all clojure data types via shared namespaces since they're loaded by the same classloader. A side effect of the implementation is that it is possible to copy namespaces from one environment to another if you have the pointer returned from creating the environment. I have considered adding automatic creation of dynamic classloaders and associating them with isolation environments but that can be done from libraries using existing clojure features. For future reference since additional features will likely be added to this fork, this feature is implemented via the git commit https://github.com/rritoch/clojure/commit/0f4804bbf584049fd85ffa872f10522cc41eff9a -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure@googlegroups.com'); Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com'); For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com javascript:_e(%7B%7D,'cvml','clojure%2bunsubscr...@googlegroups.com');. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [ClojureScript] Re: ANN: ClojureScript 0.0-2411
Thanks, fixed! David On Sun, Dec 7, 2014 at 7:01 PM, Shaun LeBron shaunewilli...@gmail.com wrote: might need to update the readme with this latest version On Friday, December 5, 2014 2:03:25 PM UTC-6, David Nolen wrote: ClojureScript, the Clojure compiler that emits JavaScript source code. README and source code: https://github.com/clojure/clojurescript New release version: 0.0-2411 Leiningen dependency information: [org.clojure/clojurescript 0.0-2411] Feedback welcome! ### Enhancements * forcing source maps to load for dynamic js reloads * All ISeqable types are now ES6 iterable * CLJS-863: Invalid arity error when calling 0-arity multimethod * CLJS-622: better error reporting for zero arity protocol methods * CLJS-506: expose more Closure minification knobs ### Changes * CLJS-807: Emitter cannot emit BigInt or BigDecimal * CLJS-749: Ignore .repl-* given that CLJS version is appended by default. * CLJS-749: Append CLJS version to browser repl-env * CLJS-749: *clojurescript-version* is unbound return empty string * implement INamed for multi-method * revert CLJS-801 * CLJS-888: Omit redundant {} around emitted recur * CLJS-888: Better placement of newlines in emitter * Join preambles with newline line to catch cases with files without newlines. * add js-in interop macro * Add nthrest * CLJS-510: Throw error when :output-wrapper and :optimizations :whitespace combined * CLJS-875: bump tools.reader dep to 0.8.10 * CLJS-879: add `update` from Clojure 1.7 * CLJS-857: change deftype*/defrecord* special forms to include their inline methods decls ### Fixes * CLJS-885: relax type inference around numbers * fix var resolution bug pointed out by Brandon Bloom * CLJS-853: propagate read-time metadata on fn and reify forms at runtime * CLJS-716: support hashing of JavaScript dates * CLJS-814: clojure.string/reverse breaks surrogate pairs * Recursively check IEncodeClojure in js-clj * CLJS-873: non-higher-order calls to array-map should return PAMs * CLJS-881: check for duplicate keys in array-map * select-keys did not preserve metadata -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups ClojureScript group. To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescr...@googlegroups.com. Visit this group at http://groups.google.com/group/clojurescript. -- 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: Open html file in Clojure
Nope. It barely renders HTML3. JavaFX, I think, has a real embedded browser component. And, of course, it's always easy to just launch a browser: http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html#browse%28java.net.URI%29 Dave On Mon, Dec 8, 2014 at 4:23 AM, Gary Verhaegen gary.verhae...@gmail.com wrote: This seems to be what Fluid is talking about: https://docs.oracle.com/javase/tutorial/uiswing/components/html.html I wiuld be a bit wary, however: I doubt this is a complete implementation of an HTML5-compatible browser with state of the art JavaScript interpreter. It's worth trying, but I would not really bet on that being able to display a Google Maps widget. On Monday, 8 December 2014, Fluid Dynamics a2093...@trbvm.com wrote: On Sunday, December 7, 2014 6:50:54 PM UTC-5, juan.facorro wrote: Hi Priyanka, I don't think there's enough information for someone to be able to help you. When you say .html do you mean JavaScript or ClojureScript code? It will be a lot easier to help you, if you share the code from the desktop app and the code you are using to get the location information. It sounds like he just wants to display a web page in his app, and has its URL. I think there may be Java Swing components that can do that. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: atoms, memoize, future-s and CAS
Most of the cache implementations in core.cache have no side-effects. They simply return a new cache rather than overwriting the old one. The memoize library places the cache in an atom, so it's guaranteed to change atomically. I tried to read the cache code (btw an excellent exercise) , and I think I understand how persistent data structure/atom is employed here in case we deal with side effects free functions. You could write this as a function. There's nothing in there that requires a macro. (defn when-map-future-swap! [a k f] (locking a (when-not (contains? @a k) (swap! a assoc k nil) (future (swap! a assoc k (f k)) I realized that later too ... But I'd personally just use a delay rather than locking for this purpose. It is not that I like locking at all. However I still fail to see, how in a multithreaded context memoize/cache prevents executing a given function more than once (which I want to avoid at any cost here) since cache lookup and swap! does not seem to be atomic : https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L52 . Best regards, Andy -- 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.
New Functional Programming Job Opportunities
Here are some functional programming job opportunities that were posted recently: Senior Software Engineer at McGraw-Hill Education http://functionaljobs.com/jobs/8771-senior-software-engineer-at-mcgraw-hill-education Software Engineer at UC Santa Cruz http://functionaljobs.com/jobs/8770-software-engineer-at-uc-santa-cruz Cheers, Sean Murphy FunctionalJobs.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/d/optout.
clojure.main on a clj file does not show up any println
I have been trying all my bit on to get my hello world working; Any help is much appreciated... am trying to run it by java -cp clojure-1.6.0.jar clojure.main hey.clj I just get an empty line. Below is my file: (defn -main [] (println Hello World!) (println (- 1 1))) -- 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: Open html file in Clojure
Perhaps it could be as simple as browse-url http://clojuredocs.org/clojure.java.browse/browse-url .. On Monday, December 8, 2014 5:44:10 PM UTC+1, daveray wrote: Nope. It barely renders HTML3. JavaFX, I think, has a real embedded browser component. And, of course, it's always easy to just launch a browser: http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html#browse%28java.net.URI%29 Dave On Mon, Dec 8, 2014 at 4:23 AM, Gary Verhaegen gary.ve...@gmail.com javascript: wrote: This seems to be what Fluid is talking about: https://docs.oracle.com/javase/tutorial/uiswing/components/html.html I wiuld be a bit wary, however: I doubt this is a complete implementation of an HTML5-compatible browser with state of the art JavaScript interpreter. It's worth trying, but I would not really bet on that being able to display a Google Maps widget. On Monday, 8 December 2014, Fluid Dynamics a209...@trbvm.com javascript: wrote: On Sunday, December 7, 2014 6:50:54 PM UTC-5, juan.facorro wrote: Hi Priyanka, I don't think there's enough information for someone to be able to help you. When you say .html do you mean JavaScript or ClojureScript code? It will be a lot easier to help you, if you share the code from the desktop app and the code you are using to get the location information. It sounds like he just wants to display a web page in his app, and has its URL. I think there may be Java Swing components that can do that. -- 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 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: debugging MyClass cannot be cast to MyClass exceptions
Assuming this is something to do with class loaders going wrong, how would I approach finding the code paths involved? Could I identify where the class is being loaded; set breakpoints at those places to get the stack traces? Something else? In my case it seems to be triggered by a type hint on a function argument that is a record. On Sunday, December 7, 2014 11:46:01 AM UTC-8, Brian Craft wrote: Not sure if I followed the non-interactive case. Is it just 1) deftype or defrecord in one file 2) import the class in a different file 3) AOT compile (e.g. uberjar)? On Saturday, December 6, 2014 11:07:36 PM UTC-8, Ambrose Bonnaire-Sergeant wrote: Perhaps this issue is biting you http://dev.clojure.org/jira/browse/CLJ-979 Thanks, Ambrose On Sat, Dec 6, 2014 at 5:22 PM, Brian Craft craft...@gmail.com wrote: Yes, I know. ;) In this case it's happening with an uberjar, not with the repl. I do java -jar myapp.jar, and later, while it is processing data, get this exception. No repl involved. On Saturday, December 6, 2014 2:02:01 PM UTC-8, juan.facorro wrote: Hi Brian, This problem usually happens when working on the REPL and you redefine a record or type (derecord and deftype), but there are still some existing instances lying around, that belong to the previous definition of that same type. See this thread for more information: https://groups. google.com/forum/#!msg/clojure/N2ivUM8bvB8/xgiFVtsXKnkJ Cheers, Juan On Saturday, December 6, 2014 5:55:23 PM UTC-3, Brian Craft wrote: I'm experimenting with jwrapper, and am getting runtime exceptions like this, due to some jar manipulation that it's doing. I know one of the steps is pack200, however running pack200 manually doesn't create these issues. Anyone have suggestions for debugging this? I've seen this type of error countless times in clojure, but only when reloading interactively. This is the first time I've see it when running an uberjar. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clo...@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+u...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com 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 Monger 2.0.1 is released
Monger [1] is a Clojure MongoDB driver for a more civilized age. Release notes: http://blog.clojurewerkz.org/blog/2014/12/08/monger-2-dot-0-1-is-released/ 1. http://clojuremongodb.info -- @michaelklishin, github.com/michaelklishin -- 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: Clojure on iOS devices - Swift as a host?
Austin Zheng has some code here https://github.com/austinzheng/swift-lambdatron that implements the basic syntax of Clojure with a REPL but does not compile to LLVM bitcode yet. He's working on some cool ideas. I really like Mike Fikes work on Goby and the example app Shrimp, and I've been experimenting with them. However, a native solution that does not require Objective C wrappers would be much easier to maintain. I'd really like to see it take off... BTW, nobody has mentioned RoboVM yet; it is an alternative to run real JVM Clojure on iOS. --Sven On Wednesday, June 4, 2014 9:20:22 AM UTC-4, Greg Knapp wrote: The recent release of Swift made me revisit Clojure on LLVM. This post from 2010 https://groups.google.com/d/msg/clojure/KrwtTsdYZ8I/Qf8PSMeoZCUJ suggests it's a very difficult task. Swift would make this job easier? As with ClojureScript, generate Swift code / provide interop and Clojurian's can produce native iOS apps? Perhaps the biggest hole to be filled would be tooling (Xcode is not Clojure/Lisp friendly? i.e. no playground support) -- 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: Clojure on iOS devices - Swift as a host?
Here is a project by Austin Zheng to implement Clojure in Swift https://github.com/austinzheng/swift-lambdatron (swift-lambdatron). He has some basics implemented with a REPL, but it does not compile to LLVM bitcode yet. He's talking about moving to Rust somehow… I'm still pretty new to Clojure, so I'm not sure what I'll be able to offer in language implementation yet. :-) I've been experimenting with Mike Fikes Goby code https://github.com/mfikes/goby and I like what he's done using ClojureScript (see Shrimp example app). However a native solution able to access the Swift iOS API would be much easier and require less maintenance long-term. Anybody else interested in making it happen? --Sven On Wednesday, June 4, 2014 9:20:22 AM UTC-4, Greg Knapp wrote: The recent release of Swift made me revisit Clojure on LLVM. This post from 2010 https://groups.google.com/d/msg/clojure/KrwtTsdYZ8I/Qf8PSMeoZCUJ suggests it's a very difficult task. Swift would make this job easier? As with ClojureScript, generate Swift code / provide interop and Clojurian's can produce native iOS apps? Perhaps the biggest hole to be filled would be tooling (Xcode is not Clojure/Lisp friendly? i.e. no playground support) -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
On Monday, December 8, 2014 9:32:28 AM UTC-5, Las wrote: Still, this is awkward, verbose, and prevents the (nontrivial) use of edn in a platform-neutral way by referring only to Clojure functions without direct interop. Well, except for the even more awkward workaround of slurp and read-string, with the accompanying need to hold the entire file in memory *twice* for a short time. As far as why it requires a PushbackReader, I didn't design the API. Yes, some things in Clojure require using Java interop, and in many (but not all) cases, file I/O requires it. Perhaps io/reader should output a PushbackReader, if only for convenience's sake. io/reader is not meant to be used solely as an input to edn/read. AFAICT, PushbackReader is substitutable anywhere a reader is expected, but apparently a plain unwrapped BufferedReader is not. -- 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: atoms, memoize, future-s and CAS
On 8 December 2014 at 17:54, Andy L core.as...@gmail.com wrote: But I'd personally just use a delay rather than locking for this purpose. It is not that I like locking at all. However I still fail to see, how in a multithreaded context memoize/cache prevents executing a given function more than once (which I want to avoid at any cost here) since cache lookup and swap! does not seem to be atomic : https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L52 When you say (delay (foo)), foo will be called at most once, regardless of how many times you deref (@) / force the delay. (If you never force the delay, it will not be called at all.) The way this is enforced is through making deref a synchronized method on delays. Cheers, Michał -- 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: Open html file in Clojure
On Monday, December 8, 2014 11:44:10 AM UTC-5, daveray wrote: Nope. It barely renders HTML3. JavaFX, I think, has a real embedded browser component. That's what I meant. And, of course, it's always easy to just launch a browser: http://docs.oracle.com/javase/6/docs/api/java/awt/Desktop.html#browse%28java.net.URI%29 That's platform-neutral? The main way I'm familiar with for launching an external process with ProcessBuilder sure isn't. This will launch the user's default browser to a specified site in Windows: (.start (ProcessBuilder. [cmd /c \start http://www.example.com\;])) and I haven't the foggiest how to do something analogous with any of the popular Unix WMs, though spawning a console Lynx process with ProcessBuilder will usually work if the site only needs to display text, and the resulting Process's input and output streams can be manipulated from inside Clojure, so you can even provide your own in-app terminal emulation wrapping the Lynx instance. Needless to say, though, Lynx isn't an option if you want to display Google Maps. :) *checking* Well, (.browse (java.awt.Desktop/getDesktop) (java.net.URI. http://www.example.com;)) works on Windoze, which is all I can test on ATM. Looks like this class can also be used to open documents with native file associations. I just got it to pop up a jpg in the Windows picture previewer. I wonder why they tucked this thing away in awt when it has nothing to do with implementing your own program GUI, instead of it being in java.lang right next to ProcessBuilder. And didn't mention it in the Java Tutorial back in the day when I was still new to the JVM and its class library. -- 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: Clojure on iOS devices - Swift as a host?
On Monday, December 8, 2014 1:45:43 PM UTC-5, Sven Pedersen wrote: Austin Zheng has some code here https://github.com/austinzheng/swift-lambdatron that implements the basic syntax of Clojure with a REPL but does not compile to LLVM bitcode yet. He's working on some cool ideas. I really like Mike Fikes work on Goby and the example app Shrimp, and I've been experimenting with them. However, a native solution that does not require Objective C wrappers would be much easier to maintain. I'd really like to see it take off... BTW, nobody has mentioned RoboVM yet; it is an alternative to run real JVM Clojure on iOS. Do either of those *not* require jailbreaking the phone? Does LLVM support fixnums? TCO? -- 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: atoms, memoize, future-s and CAS
On Monday, December 8, 2014 3:34:05 PM UTC-5, Michał Marczyk wrote: On 8 December 2014 at 17:54, Andy L core@gmail.com javascript: wrote: But I'd personally just use a delay rather than locking for this purpose. It is not that I like locking at all. However I still fail to see, how in a multithreaded context memoize/cache prevents executing a given function more than once (which I want to avoid at any cost here) since cache lookup and swap! does not seem to be atomic : https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L52 When you say (delay (foo)), foo will be called at most once, regardless of how many times you deref (@) / force the delay. (If you never force the delay, it will not be called at all.) The way this is enforced is through making deref a synchronized method on delays. Which means it's locking or bust. You just get to either do the locking yourself or delegate :) -- 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: atoms, memoize, future-s and CAS
Oh, and as for how to use it here, you could for example say (.putIfAbsent concurrent-hash-map :foo (delay (foo))) Then the first thread to @(get concurrent-hash-map :foo (delay :not-found)) (or similar) would actually compute the value. With a map in an atom, you could swap! using a function like (fn [old-state] (if (contains? old-state :foo) (assoc old-state :foo (delay (foo))) old-state)) I'd probably prefer a CHM for this purpose, though. Michał On 8 December 2014 at 21:33, Michał Marczyk michal.marc...@gmail.com wrote: On 8 December 2014 at 17:54, Andy L core.as...@gmail.com wrote: But I'd personally just use a delay rather than locking for this purpose. It is not that I like locking at all. However I still fail to see, how in a multithreaded context memoize/cache prevents executing a given function more than once (which I want to avoid at any cost here) since cache lookup and swap! does not seem to be atomic : https://github.com/clojure/core.cache/blob/master/src/main/clojure/clojure/core/cache.clj#L52 When you say (delay (foo)), foo will be called at most once, regardless of how many times you deref (@) / force the delay. (If you never force the delay, it will not be called at all.) The way this is enforced is through making deref a synchronized method on delays. Cheers, Michał -- 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: atoms, memoize, future-s and CAS
On 8 December 2014 at 21:46, Fluid Dynamics a2093...@trbvm.com wrote: [...] Which means it's locking or bust. You just get to either do the locking yourself or delegate :) Sure, but isn't it nice when somebody else does your locking for you? :-) Incidentally, there is a trade-off here between lockless reads and cache-locking writes in the version with (locking …) and synchronized reads (of delays) and somewhat concurrency-friendly writes in the version with CHM.putIfAbsent and delays. So actually explicit (locking …) might be preferable for certain workloads. Benchmarking required. Michał -- 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.
Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
On 8 December 2014 at 21:17, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 9:32:28 AM UTC-5, Las wrote: […] io/reader is not meant to be used solely as an input to edn/read. AFAICT, PushbackReader is substitutable anywhere a reader is expected, but apparently a plain unwrapped BufferedReader is not. user= (line-seq (java.io.PushbackReader. (io/reader (io/file .bashrc ClassCastException java.io.PushbackReader cannot be cast to java.io.BufferedReader clojure.core/line-seq (core.clj:2955) It works with the plain unwrapped BufferedReader that io/reader returns. Unfortunately PushbackReader and BufferedReader are both classes rather than interfaces and they both have methods that the other class does not. So, there isn't a single good choice for what a reader function in Clojure on the JVM should return. Cheers, Michał -- 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.
Re: clojure.main on a clj file does not show up any println
On Dec 8, 2014, at 9:02 AM, Ganesh Krishnamoorthy ganesh@gmail.com wrote: I have been trying all my bit on to get my hello world working; Any help is much appreciated... am trying to run it by java -cp clojure-1.6.0.jar clojure.main hey.clj I just get an empty line. Below is my file: (defn -main [] (println Hello World!) (println (- 1 1))) That calling syntax for clojure.main executes the contents of the hey.clj file. Your file defines a -main function, but no code will call it. If you add a call to your main function, it runs: (-main) There are other options for clojure.main. There’s more info here: http://clojure.org/repl_and_main http://clojure.org/repl_and_main and here: http://www.beaconhill.com/blog/?p=283 http://www.beaconhill.com/blog/?p=283 —Steve -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
On Monday, December 8, 2014 4:01:28 PM UTC-5, Michał Marczyk wrote: On 8 December 2014 at 21:17, Fluid Dynamics a209...@trbvm.com javascript: wrote: On Monday, December 8, 2014 9:32:28 AM UTC-5, Las wrote: […] io/reader is not meant to be used solely as an input to edn/read. AFAICT, PushbackReader is substitutable anywhere a reader is expected, but apparently a plain unwrapped BufferedReader is not. user= (line-seq (java.io.PushbackReader. (io/reader (io/file .bashrc ClassCastException java.io.PushbackReader cannot be cast to java.io.BufferedReader clojure.core/line-seq (core.clj:2955) It works with the plain unwrapped BufferedReader that io/reader returns. Unfortunately PushbackReader and BufferedReader are both classes rather than interfaces and they both have methods that the other class does not. So, there isn't a single good choice for what a reader function in Clojure on the JVM should return. Jeez. Who made this mess? And what happens on other VM targets? What does line-seq expect in CLJS or CLR? -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
To Fluid Dynamics: I attempted to send this privately to the email address a2093...@trbvm.com, but got a permanent failure to deliver. Hence the open letter. I understand that some things do not work as you wish them to, and I understand that one can be frustrated or shocked by the state of libraries that you find confusing or broken, but there are other ways to express this that can be less inflammatory. For example, instead of Jeez. Who made this mess? one might say That's an unfortunate state of affairs. Do you know how it got this way, or whether there are existing Clojure libraries that smooth some of this over for the developer? Thanks, Andy Fingerhut On Mon, Dec 8, 2014 at 1:13 PM, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 4:01:28 PM UTC-5, Michał Marczyk wrote: On 8 December 2014 at 21:17, Fluid Dynamics a209...@trbvm.com wrote: On Monday, December 8, 2014 9:32:28 AM UTC-5, Las wrote: […] io/reader is not meant to be used solely as an input to edn/read. AFAICT, PushbackReader is substitutable anywhere a reader is expected, but apparently a plain unwrapped BufferedReader is not. user= (line-seq (java.io.PushbackReader. (io/reader (io/file .bashrc ClassCastException java.io.PushbackReader cannot be cast to java.io.BufferedReader clojure.core/line-seq (core.clj:2955) It works with the plain unwrapped BufferedReader that io/reader returns. Unfortunately PushbackReader and BufferedReader are both classes rather than interfaces and they both have methods that the other class does not. So, there isn't a single good choice for what a reader function in Clojure on the JVM should return. Jeez. Who made this mess? And what happens on other VM targets? What does line-seq expect in CLJS or CLR? -- 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.
Re: Clojure on iOS devices - Swift as a host?
All the options I mentioned -- swift-lambdatron, Goby, and RoboVM can be used to make apps to submit to the app store. None require jail breaking. Goby and RoboVM have been used for apps that were accepted. The compiled form of each app is a bonified Objective-C style LLVM binary. The ClojureSwift hopeful, swift-lambdatron, is not yet ready to make apps. --Sven On Mon, Dec 8, 2014 at 3:45 PM, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 1:45:43 PM UTC-5, Sven Pedersen wrote: Austin Zheng has some code here https://github.com/austinzheng/swift-lambdatron that implements the basic syntax of Clojure with a REPL but does not compile to LLVM bitcode yet. He's working on some cool ideas. I really like Mike Fikes work on Goby and the example app Shrimp, and I've been experimenting with them. However, a native solution that does not require Objective C wrappers would be much easier to maintain. I'd really like to see it take off... BTW, nobody has mentioned RoboVM yet; it is an alternative to run real JVM Clojure on iOS. Do either of those *not* require jailbreaking the phone? Does LLVM support fixnums? TCO? -- 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/HaswRFJw29g/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/d/optout. -- ``All that is gold does not glitter, not all those who wander are lost; the old that is strong does not wither, deep roots are not reached by the frost. From the ashes a fire shall be woken, a light from the shadows shall spring; renewed shall be blade that was broken, the crownless again shall be king.” -- 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: Ring and Compojure with Node.js via Clojurescript
Awesome! I look forward to seeing the results. On Monday, December 8, 2014 3:50:48 PM UTC+1, Matthew Molloy wrote: Dear Community, I love making Clojure web apps, however their startup time is a serious drawback when used with a transient hosting service such as Heroku. My thought is to port Ring and Compojure over to Clojurescript so that can get their nice abstractions hosted on the Node.js runtime. Any thoughts or suggestions? Matthew -- 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 do you think about this code?
TIL: butlast Nice. Philip On Saturday, 6 December 2014 13:36:47 UTC, David Della Costa wrote: Hi Philip, I read your message and immediately wanted to try it myself--I intended to leave it at that but I realized I would be remiss if I did not give you a little bit of feedback based on my experience. I should add that I was kind of fast and loose with my solution (that is, I didn't really read the instructions), but it does print out the diamond shape according to what I saw in the blog post examples. First of all, here's what I came up with: https://gist.github.com/ddellacosta/ba7e03951ba1bafd3ec9 As you said, you weren't looking for alternative algorithms and I recognize that that's not the point. But there are a few things that I think are good and/or common Clojure practice that I think I've internalized, and writing out an alternative solution helped me to see them. - I'm assuming you used a TDD process to write this (correct me if wrong--basing that on the articles you linked to), but I think a repl-driven process may be more common for working through a problem like this--i.e. something you can wrap your head around as a whole and solve iteratively. That's not to say I and others don't use TDD in Clojure dev, but just that it's also quite common to do a lot of this kind of development in the repl. - you're grouping your side-effecting code w/the code that generates the diamond data structure here: https://gist.github.com/ddellacosta/ba7e03951ba1bafd3ec9 While of course the diamond kata is a bit contrived and the point is to print stuff out in the end, it also looks like you are trying to be thoughtful about how you structure your code. So I would suggest isolating your pure functions from your side-effecting code as a sort of basic separation, and avoid monolithic functions like the one I linked to above. This gives you the freedom to apply the data structure to other processes if need be, rather than having to refactor that code later on as soon as you need to do something other than printing to the final diamond data structure. That is a more compositional approach that is good to follow as part of functional programming practice in general. And otherwise it seems like you are following this approach--I think you can see this in the shape of your code overall. - Stylistically, I found your naming conventions to be too verbose, with not enough information about the actual input and output--I would prefer a style like I used in my solution which aims for readable conciseness, while documenting what is going in and coming out of my functions. I assume Clojure developers reading my code will have a good understanding of the core data structures and functions available to manipulate them, and so I want to leverage that as much as possible in how I write and document my code. In fact, at this point I prefer using Prismatic's schema ( https://github.com/Prismatic/schema) to document as well as provide further safety for my functions, and am of the opinion that Clojure's one glaring weakness is its approach to typing--but that's another discussion and I recognize this is not necessarily a widely-held opinion. More generally, I think reasonable people could disagree on naming conventions and so I would hesitate to say you're doing something wrong here--I would rather say: the more Clojure code you read the more you'll get a sense of how people tend to write. You'll figure out what you want to adopt in your own style, and what Clojure devs are going to expect. - I don't want to get too deep into the algorithm itself but I think you would find it more natural to work line by line vs. the way you constructed blocks and flipped them right/left, and you'd have less code overall. I will boldly claim that my solution may be closer to how other developers familiar with Clojure (or functional programming in general) may approach it--not that I'm claiming it's the best approach. I do think it is more concise without sacrificing readability (which is subjective, I fully appreciate). - I don't know if I've ever once used a main function, and you don't see them in libraries, certainly. But that is minor--there's no reason *not* to use it, just that I wouldn't expect to see it. I hope this is useful feedback--good luck in your journey and enjoy Clojure! Dave 2014-12-06 19:48 GMT+09:00 Philip Schwarz philip.joh...@googlemail.com javascript:: Hello, can you please review my first solution to the diamond kata [1] and tear it to bits: let me know all the ways in which YOU would improve the code. I am not so interested in a better algorithm for solving the kata. I am learning Clojure and what I want to know is what YOU would do to make the code more readable/understandable/maintainable, or just to make it follow Clojure idioms and/or conventions that YOU find
Re: Clojure on iOS devices - Swift as a host?
Also worth mentioning is Gal Dolber's project https://github.com/galdolber/clojure-objc. It's a modified version of the Clojure compiler which outputs Java source instead of bytecode, and then uses Google's J2Objc project. It's pretty neat - he has two iOS apps live which were totally written in Clojure. On 9 December 2014 at 11:24, Sven Pedersen sven.peder...@gmail.com wrote: All the options I mentioned -- swift-lambdatron, Goby, and RoboVM can be used to make apps to submit to the app store. None require jail breaking. Goby and RoboVM have been used for apps that were accepted. The compiled form of each app is a bonified Objective-C style LLVM binary. The ClojureSwift hopeful, swift-lambdatron, is not yet ready to make apps. --Sven On Mon, Dec 8, 2014 at 3:45 PM, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 1:45:43 PM UTC-5, Sven Pedersen wrote: Austin Zheng has some code here https://github.com/austinzheng/swift-lambdatron that implements the basic syntax of Clojure with a REPL but does not compile to LLVM bitcode yet. He's working on some cool ideas. I really like Mike Fikes work on Goby and the example app Shrimp, and I've been experimenting with them. However, a native solution that does not require Objective C wrappers would be much easier to maintain. I'd really like to see it take off... BTW, nobody has mentioned RoboVM yet; it is an alternative to run real JVM Clojure on iOS. Do either of those *not* require jailbreaking the phone? Does LLVM support fixnums? TCO? -- 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/HaswRFJw29g/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/d/optout. -- ``All that is gold does not glitter, not all those who wander are lost; the old that is strong does not wither, deep roots are not reached by the frost. From the ashes a fire shall be woken, a light from the shadows shall spring; renewed shall be blade that was broken, the crownless again shall be king.” -- 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.
Re: what do you think about this code?
Hello David, I had set myself the constraint that I wanted the solution to exploit two symmetries: (1) The top left and top right of the diamond are mirror images (2) The top half and bottom half of the diamond are also mirror images I'm assuming you used a TDD process to write this (correct me if wrong--basing that on the articles you linked to) I was on a train commuting back home, and what I did was sit in a loop where I wrote some code and then tweaked it until executing it in the REPL gave me the part of the diamond that I wanted, by eyeballing the console output. What a coincidence that in your gist you linked to http://blog.jayfields.com/2014/01/repl-driven-development.html . I was looking at exactly that blog post on Sunday to determine if what I had been doing could be classified as REPL-based? Still not sure. Thoughts? My first version of the code was this https://gist.github.com/philipschwarz/c7e3be1ac97e482d04bf: (defn print-diamond [letter] (let [alphabet ABCDEFGHIJKLMNOPQRSTUVWXYZ position-of (fn [letter] (inc (- (int letter) (int \A number-of-letters (position-of letter) dashes (fn [n] (repeat n \-)) fixed-text-for (fn [letter] (concat (dashes (dec (position-of letter))) (list letter))) template (map fixed-text-for (take number-of-letters alphabet)) pad-with-trailing-dashes (fn [index line] (concat line (dashes (dec (- number-of-letters index) top-right-quadrant (map-indexed pad-with-trailing-dashes template) top-left-quadrant (map reverse (map rest (take number-of-letters top-right-quadrant))) top-half (map concat top-left-quadrant top-right-quadrant) diamond (concat top-half (drop 1 (reverse top-half)))] (doseq [line (map #(apply str %) diamond)] (println line I showed it to Extreme Programming and Agile Guru Ron Jeffries, and the following conversation ensued: @philip_schwarz 1st stab at Clojure print-diamond using symmetries identified by @TotherAlistair @RonJeffries @gdinwiddie @sebrose https://gist.github.com/philipschwarz/c7e3be1ac97e482d04bf @RonJeffries @philip_schwarz *can people read that and figure out what it does? *i can't but not a closure person. @totheralistair @gdinwiddie @sebrose @philip_schwarz @RonJeffries @TotherAlistair @gdinwiddie @sebrose *I like defns of top-half diamond think they r graspable-ish; top-left-quadrant less so* @philip_schwarz one interesting Q for us all is *if one didn't know the prob could one grok the prog* @totheralistair @gdinwiddie @sebrose @gdinwiddie .@RonJeffries I think *the program is generally easier to grok if you've got the tests, too.* @philip_schwarz @TotherAlistair @sebrose @philip_schwarz Dec 3 @gdinwiddie @RonJeffries @TotherAlistair @sebrose agree - I have added tests: https://github.com/philipschwarz/diamond-problem-in-clojure/blob/master/test/diamond_problem_in_clojure/core_test.clj I notice you did not write tests. I also notice that you added comments to your methods. I like your comments. Find them useful. I am not saying the following applies to your comments, but it will give you an idea of the programming culture I am part of. In that culture, comments are looked at with suspicion: e.g. 1: https://twitter.com/nzkoz/status/538892801941848064 https://pbs.twimg.com/media/B3qIJLFCcAEJLWm.jpg e.g. 2: The proper use of comments is to compensate for our failure to express ourself in code. - Robert C. Martin e.g. 3: Comments often are used as a deodorant... often comments are there because the code is bad. - Martin Fowler e.g. 4: - Primary Rule: Comments are for things that *cannot* be expressed in code. - Redundancy Rule: Comments which restate code must be deleted. - Single Truth Rule: If the comment says what the code *could* say, then the code must change to make the comment redundant. In that culture, we aim to use certain implementation patterns that make comments unnecessary. Also, where possible, the tests act as (executable, more reliable) documentation. Moving on, after writing the terse first version of the code, I set out to *make my code more readable*. Are you familiar with Robert Martin's dictum?: The Three Functions of a s/w module: * The function it performs while executing * To afford change. A module that is difficult to change is broken and needs fixing, even though it works * *To communicate to its readers. A module that does not communicate is broken and needs fixing.* The rationale for making code more readable is an economic one. Here is a brief summary of Ken't Beck's thoughts on the matter: o Economics is the underlying driver of software design o Software should be designed to reduce its overall cost o COST(total) = COST(develop) + COST(maintain) o The cost of maintenance is much higher than the initial cost of development o Maintenance is expensive because understanding existing code is time-consuming and
Re: what do you think about this code?
btw, my first impression when first looking at your solution is positive - the feeling I get is that I probably won't have problems understanding how it works Philip On Saturday, 6 December 2014 13:36:47 UTC, David Della Costa wrote: Hi Philip, I read your message and immediately wanted to try it myself--I intended to leave it at that but I realized I would be remiss if I did not give you a little bit of feedback based on my experience. I should add that I was kind of fast and loose with my solution (that is, I didn't really read the instructions), but it does print out the diamond shape according to what I saw in the blog post examples. First of all, here's what I came up with: https://gist.github.com/ddellacosta/ba7e03951ba1bafd3ec9 As you said, you weren't looking for alternative algorithms and I recognize that that's not the point. But there are a few things that I think are good and/or common Clojure practice that I think I've internalized, and writing out an alternative solution helped me to see them. - I'm assuming you used a TDD process to write this (correct me if wrong--basing that on the articles you linked to), but I think a repl-driven process may be more common for working through a problem like this--i.e. something you can wrap your head around as a whole and solve iteratively. That's not to say I and others don't use TDD in Clojure dev, but just that it's also quite common to do a lot of this kind of development in the repl. - you're grouping your side-effecting code w/the code that generates the diamond data structure here: https://gist.github.com/ddellacosta/ba7e03951ba1bafd3ec9 While of course the diamond kata is a bit contrived and the point is to print stuff out in the end, it also looks like you are trying to be thoughtful about how you structure your code. So I would suggest isolating your pure functions from your side-effecting code as a sort of basic separation, and avoid monolithic functions like the one I linked to above. This gives you the freedom to apply the data structure to other processes if need be, rather than having to refactor that code later on as soon as you need to do something other than printing to the final diamond data structure. That is a more compositional approach that is good to follow as part of functional programming practice in general. And otherwise it seems like you are following this approach--I think you can see this in the shape of your code overall. - Stylistically, I found your naming conventions to be too verbose, with not enough information about the actual input and output--I would prefer a style like I used in my solution which aims for readable conciseness, while documenting what is going in and coming out of my functions. I assume Clojure developers reading my code will have a good understanding of the core data structures and functions available to manipulate them, and so I want to leverage that as much as possible in how I write and document my code. In fact, at this point I prefer using Prismatic's schema ( https://github.com/Prismatic/schema) to document as well as provide further safety for my functions, and am of the opinion that Clojure's one glaring weakness is its approach to typing--but that's another discussion and I recognize this is not necessarily a widely-held opinion. More generally, I think reasonable people could disagree on naming conventions and so I would hesitate to say you're doing something wrong here--I would rather say: the more Clojure code you read the more you'll get a sense of how people tend to write. You'll figure out what you want to adopt in your own style, and what Clojure devs are going to expect. - I don't want to get too deep into the algorithm itself but I think you would find it more natural to work line by line vs. the way you constructed blocks and flipped them right/left, and you'd have less code overall. I will boldly claim that my solution may be closer to how other developers familiar with Clojure (or functional programming in general) may approach it--not that I'm claiming it's the best approach. I do think it is more concise without sacrificing readability (which is subjective, I fully appreciate). - I don't know if I've ever once used a main function, and you don't see them in libraries, certainly. But that is minor--there's no reason *not* to use it, just that I wouldn't expect to see it. I hope this is useful feedback--good luck in your journey and enjoy Clojure! Dave 2014-12-06 19:48 GMT+09:00 Philip Schwarz philip.joh...@googlemail.com javascript:: Hello, can you please review my first solution to the diamond kata [1] and tear it to bits: let me know all the ways in which YOU would improve the code. I am not so interested in a better algorithm for solving the kata. I am learning Clojure and what I want to know is what YOU would
Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
As the original author of the function that eventually became clojure.java.io/reader, it was one of those unfortunate decisions that seemed like a good idea at the time and cannot be changed without breaking backwards compatibility. Long before EDN existed, I wrote clojure.contrib.io https://github.com/clojure/clojure-contrib/blob/1.2.x/src/main/clojure/clojure/contrib/io.clj This included a function `reader` that returned a java.io.BufferedReader: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html BufferedReader was a convenient type to return because it supports .readLine, which is used by clojure.core/line-seq: https://github.com/clojure/clojure/blob/1.1.x/src/clj/clojure/core.clj#L1954-L1960 However, clojure.core/read and later clojure.edn/read were written in terms of java.io.PushbackReader, because they need the ability to look ahead one character in the stream while parsing it: http://docs.oracle.com/javase/7/docs/api/java/io/PushbackReader.html java.io.PushbackReader and java.io.BufferedReader are both subclasses of java.io.Reader, but there is no class in the JDK which combines the features of both PushbackReader and BufferedReader. Java does not permit multiple inheritance of concrete classes. In Java it is common to have several layers of Reader sub-classes wrapped around each other, so that's what we do. We cannot change clojure.java.io/reader to return a different type without breaking a lot of existing code that expects it to return a BufferedReader. This was reported as an issue in 2009 and discussed on the mailing list: https://groups.google.com/forum/#!topic/clojure/_tuypjr2M_A http://dev.clojure.org/jira/browse/CLJ-82 It turns out there are some subtle issues which can cause incorrect behavior were clojure.core/read to blindly wrap a PushbackReader around its argument: https://groups.google.com/d/msg/clojure/_tuypjr2M_A/W1EcEbMUg_cJ In conclusion, this is a minor nuisance, well-known to Clojure developers, for which no good solution has been identified. –S On Sunday, December 7, 2014 11:27:05 PM UTC-5, Fluid Dynamics wrote: = (with-open [in (io/reader (io/resource foo))] (edn/read in)) ClassCastException java.io.BufferedReader cannot be cast to java.io.PushbackReader clojure.edn/read (edn.clj:35) Er, what? Aren't these things supposed to just plug into each other and work OOTB? Do I need to muck about with interop to use edn with any input source other than strings, then? -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
On Monday, December 8, 2014 7:32:29 PM UTC-5, Stuart Sierra wrote: As the original author of the function that eventually became clojure.java.io/reader, it was one of those unfortunate decisions that seemed like a good idea at the time and cannot be changed without breaking backwards compatibility. Long before EDN existed, I wrote clojure.contrib.io https://github.com/clojure/clojure-contrib/blob/1.2.x/src/main/clojure/clojure/contrib/io.clj This included a function `reader` that returned a java.io.BufferedReader: http://docs.oracle.com/javase/7/docs/api/java/io/BufferedReader.html BufferedReader was a convenient type to return because it supports .readLine, which is used by clojure.core/line-seq: https://github.com/clojure/clojure/blob/1.1.x/src/clj/clojure/core.clj#L1954-L1960 However, clojure.core/read and later clojure.edn/read were written in terms of java.io.PushbackReader, because they need the ability to look ahead one character in the stream while parsing it: http://docs.oracle.com/javase/7/docs/api/java/io/PushbackReader.html Seems like the simplest fix at the library level would be to make core/read and edn/read accept both classes and wrap BufferedReaders in PushbackReaders themselves, then. It turns out there are some subtle issues which can cause incorrect behavior were clojure.core/read to blindly wrap a PushbackReader around its argument: https://groups.google.com/d/msg/clojure/_tuypjr2M_A/W1EcEbMUg_cJ That sounds like magic. The user wrapping a PushbackReader around a BufferedReader doesn't cause problems, but the library function doing so does? Why would where the wrapping takes place make a difference? Is the *only* problem the rare case of reading more than one object from the same stream? A docstring warning to wrap manually *in those cases* would suffice, then, no? -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
How many programmers does it take to change a light bulb?! http://dev.clojure.org/jira/browse/CLJ-1611 -- 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: Clojure on iOS devices - Swift as a host?
Also, LLVM does support Swift seems to support Tail Call Optimization, according to this thread: http://stackoverflow.com/questions/24023580/does-swift-implement-tail-call-optimization-and-in-mutual-recursion-case I'm not familiar with the term fixnum, but if you mean the Ruby term for machine word size integers, I believe that Swift can do that... at least LLVM supports it. http://www.rubydoc.info/github/dubik/llvmruby/Fixnum --Sven On Mon, Dec 8, 2014 at 3:45 PM, Fluid Dynamics a2093...@trbvm.com wrote: On Monday, December 8, 2014 1:45:43 PM UTC-5, Sven Pedersen wrote: Austin Zheng has some code here https://github.com/austinzheng/swift-lambdatron that implements the basic syntax of Clojure with a REPL but does not compile to LLVM bitcode yet. He's working on some cool ideas. I really like Mike Fikes work on Goby and the example app Shrimp, and I've been experimenting with them. However, a native solution that does not require Objective C wrappers would be much easier to maintain. I'd really like to see it take off... BTW, nobody has mentioned RoboVM yet; it is an alternative to run real JVM Clojure on iOS. Do either of those *not* require jailbreaking the phone? Does LLVM support fixnums? TCO? -- 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/HaswRFJw29g/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/d/optout. -- ``All that is gold does not glitter, not all those who wander are lost; the old that is strong does not wither, deep roots are not reached by the frost. From the ashes a fire shall be woken, a light from the shadows shall spring; renewed shall be blade that was broken, the crownless again shall be king.” -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
Dunno the answer but I know how many buddhist monks are needed, exactly three: a) the first one readies itself for the bulb swap! by repeating a mantra b) the second meditates to make the first monk levitate toward the fixture c) the third one immolates itself to provide light for the entire duration of the operation Sorry for all the buddhist monks that may be offended by the above :) I like black humor very much and this is probably the only joke that I can write on this list that will not qualify me hopefully for eternal damnation... Euh moderation... Luc P. Sent from my iPad On Dec 8, 2014, at 20:11, Matching Socks phill.w...@gmail.com wrote: How many programmers does it take to change a light bulb?! http://dev.clojure.org/jira/browse/CLJ-1611 -- 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.
1.6.X latest branch
I see there is latest branches for versions: - https://github.com/clojure/clojure/tree/1.5.x - https://github.com/clojure/clojure/tree/1.3.x - https://github.com/clojure/clojure/tree/1.2.x - https://github.com/clojure/clojure/tree/1.1.x Where/Why is there no branches for 1.6 and 1.4? I would really like to know as I'm making an autobuild script to checkout and maintain a Latest Stable Jar. -- 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: 1.6.X latest branch
I can't state authoritatively why, but here is some evidence: 1.1.x and 1.3.x are identical to 1.1.0 and 1.3.0. 1.2.x and 1.5.x are equivalent to 1.2.1 and 1.5.1, respectively, which do have a few bug fixes made after the 1.2.0 and 1.5.0 releases. There were never any 1.4.x or 1.6.x releases for x 0. My guess is that starting with 1.4.0, the Clojure team decided not to bother creating a 1.n.x branch unless they actually wanted to make a 1.n.1 release, and they never did. Andy On Mon, Dec 8, 2014 at 6:48 PM, GlassGhost roypf...@gmail.com wrote: I see there is latest branches for versions: - https://github.com/clojure/clojure/tree/1.5.x - https://github.com/clojure/clojure/tree/1.3.x - https://github.com/clojure/clojure/tree/1.2.x - https://github.com/clojure/clojure/tree/1.1.x Where/Why is there no branches for 1.6 and 1.4? I would really like to know as I'm making an autobuild script to checkout and maintain a Latest Stable Jar. -- 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.
Re: 1.6.X latest branch
Is there something missing, at least for your purposes, with the JARs released via Maven for Clojure? http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.clojure%22%20AND%20a%3A%22clojure%22 I suspect you may want to make your script easy to modify for whatever is the branch that contains the latest stable release. It will need to change over time, but not very often (maybe once or twice a year, if the past few years is an accurate predictor). Andy On Mon, Dec 8, 2014 at 7:00 PM, Andy Fingerhut andy.finger...@gmail.com wrote: I can't state authoritatively why, but here is some evidence: 1.1.x and 1.3.x are identical to 1.1.0 and 1.3.0. 1.2.x and 1.5.x are equivalent to 1.2.1 and 1.5.1, respectively, which do have a few bug fixes made after the 1.2.0 and 1.5.0 releases. There were never any 1.4.x or 1.6.x releases for x 0. My guess is that starting with 1.4.0, the Clojure team decided not to bother creating a 1.n.x branch unless they actually wanted to make a 1.n.1 release, and they never did. Andy On Mon, Dec 8, 2014 at 6:48 PM, GlassGhost roypf...@gmail.com wrote: I see there is latest branches for versions: - https://github.com/clojure/clojure/tree/1.5.x - https://github.com/clojure/clojure/tree/1.3.x - https://github.com/clojure/clojure/tree/1.2.x - https://github.com/clojure/clojure/tree/1.1.x Where/Why is there no branches for 1.6 and 1.4? I would really like to know as I'm making an autobuild script to checkout and maintain a Latest Stable Jar. -- 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.
Re: ANN: Prone - better exception reporting middleware for Ring
This is brilliant! Thanks Magnar :-) ~BG On Mon, Dec 8, 2014 at 1:15 PM, Magnar Sveen magn...@gmail.com wrote: Better exception reporting middleware for Ring. Heavily inspired by better_errors for Rails https://github.com/charliesome/better_errors. See it to believe it: a quick video demoing Prone https://dl.dropboxusercontent.com/u/3378230/prone-demo.mp4. Prone presents your stack traces in a consumable form. It filters out stack frames that did not originate in your application, allowing you to focus on your code. It allows you to browse environment data, such as the request map and exception data (when using ex-info). Prone also provides a debug function that enables you to visually browse local bindings and any piece of data you pass to debug. https://github.com/magnars/prone/blob/master/screenshot.png Check it out: https://github.com/magnars/prone Any feedback welcome. :-) -- 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. -- Baishampayan Ghose b.ghose at gmail.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/d/optout.
Re: what do you think about this code?
Hi, Philip. I had the same urge as David--I tried it out, glossing over any formal rules. Here's what I came up with: https://gist.github.com/leifp/ae37c3b6f1b497f13f1e In truth, I think David's solution is more readable and maintainable. But I think maintainability is a pretty tricky concept: My code makes a seq of maps describing rows, and then turns them into strings at the end. This is probably more work to understand than David's solution. But is it less maintainable? Well, currently, the answer is yes, but what if I need to output a diamond in several different formats? What if marketing wants each row to be a different color and font? I would start to favor my solution in that case. My point is that the difference between maintainable and horrible is evident, but the difference between maintainable and easily maintainable depends on predicting the future somewhat. I also favor a slightly less verbose style. A function is an abstraction, and you seem to be writing functions for very concrete steps. I think you have most of the correct abstractions for your solution method, you just need to consolidate the more concrete steps. Something like: flip-bottom-up - flip (or vertical- and horizontal-flip) join-together-side-by-side - beside put-one-on-top-of-the-other - stack (or ontop, or ...) reverse-every-row - (map reverse rows) ; very readable to clojure programmers (let [top-right (create-top-right-quadrant-for letter) right (stack top-right (flip top-right)) diamond (beside (map reverse (drop-first-col right)) right)] (display diamond)) The broad takeaway is: if I write a function I only use once, I usually just inline it. Unless of course I believe deep in my heart I'll have need of it somewhere else soon :). This is somewhat a matter of taste, and again, the requirements history usually determines what gets abstracted into functions, and history can be messy. :) Hope that helps, Leif On Saturday, December 6, 2014 5:48:02 AM UTC-5, Philip Schwarz wrote: Hello, can you please review my first solution to the diamond kata [1] and tear it to bits: let me know all the ways in which YOU would improve the code. I am not so interested in a better algorithm for solving the kata. I am learning Clojure and what I want to know is what YOU would do to make the code more readable/understandable/maintainable, or just to make it follow Clojure idioms and/or conventions that YOU find effective, or to follow a coding style that YOU find more effective. Thanks, Philip [1] https://github.com/philipschwarz/diamond-problem-in-clojure -- 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: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?
+10 for bringing this thread around. On Monday, December 8, 2014 9:42:33 PM UTC-5, Luc wrote: Dunno the answer but I know how many buddhist monks are needed, exactly three: a) the first one readies itself for the bulb swap! by repeating a mantra b) the second meditates to make the first monk levitate toward the fixture c) the third one immolates itself to provide light for the entire duration of the operation Sorry for all the buddhist monks that may be offended by the above :) I like black humor very much and this is probably the only joke that I can write on this list that will not qualify me hopefully for eternal damnation... Euh moderation... Luc P. Sent from my iPad On Dec 8, 2014, at 20:11, Matching Socks phill...@gmail.com javascript: wrote: How many programmers does it take to change a light bulb?! http://dev.clojure.org/jira/browse/CLJ-1611 -- 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: test.check generating hierarchy with relations
Hi Gary I have tried your suggestion but I fear there is a deeper problem. Thanks Cliff On Monday, 8 December 2014 12:03:47 UTC+2, Gary Verhaegen wrote: I haven't touched test.check yet, si this might be completely off the mark, but based on my limited understanding, here's what I think happens. for-all probably removes one level of nesting from your generator, which means that bindings is bound to a seq with one element, which is a map. Then, keys in the (let [ks (into #{} (keys bindings))]... Form turns its argument into a seq, which is easy as it is already one, and then tries to map the key function on the result. The key function expects a Map.Entry, but here the elements of the seq are (or actually is, as there is only one) maps, so it blows up. Easiest way to test (I'm on my phone, emse I'd have done it) this hypothesis would be to turn the into for into (into #{} (keys (first bindings))). Once confirmed, I would suggest getting ris of that extra level of nesting earlier, for example inside your -maps fn (mapcat identity should do the trick). On Monday, 8 December 2014, cig clifford...@gmail.com javascript: wrote: Hi I would like to test a function which recursively traverses the nodes in a graph and collects them. For example, (def graph {1 [2 3 4] 2 [5 6 7] 6 [8 9] 10 [11 12 13]} my function is given a starting point say, 1 and should then traverse each node which is reachable and return the set. In this case the result should be: #{3, 4, 5, 7, 8, 9} note: it does not return any elements reachable by 10. I would like to test this using test.check, but I would like to generate test data which will exercise the traversal of the graph. I found a similar thread here: https://groups.google.com/forum/#!topic/clojure/YWeT8BFc8k4 But, I don't think the proposed solution would suit this use case. So, I tried generating a graph with relations using core.logic (defn -maps take the output of run* and convert it into sequence of maps [q] (let [r (- q (partition 2) (map (fn [[k v]] {k (apply vector v)})) (apply merge))] r )) (defn gen-hierarchy generate a related hierarchy [size] (let [vars1 (- (repeatedly 7 lvar) (into [])) vars2 (- (repeatedly 7 lvar) (into [])) vars3 (- (repeatedly 7 lvar) (into []))] (- (run size [q] (fresh [?k1 ?k2 ?k3 ?v1 ?v2 ?v3 ?a] (fd/distinct vars1) (everyg #(fd/in % (fd/interval 1 9)) vars1) (fd/in ?k1 (fd/interval 1 9)) (rembero ?k1 vars1 ?v1) (membero ?k2 ?v1) (fd/distinct vars2) (everyg #(fd/in % (fd/interval 1 9)) vars2) (rembero ?k2 vars2 ?v2) (membero ?k3 ?v2) (fd/distinct vars3) (everyg #(fd/in % (fd/interval 1 9)) vars3) (rembero ?k3 vars3 ?v3) (appendo [?k1 ?v1] [?k2 ?v2] ?a) (appendo ?a [?k3 ?v3] q))) (map -maps Hooking this into test.check. I tried the following: (defn gen-port-hierarchy [] (gen/sized (fn [size] (gen/fmap #(gen-hierarchy %) (gen/return size) (gen/sample (gen/not-empty (gen-port-hierarchy)) 1) Which does produce more or less what I'm after: (({6 [2 3 4 5 7 1], 3 [6 7 1 2 4 5], 1 [3 2 4 5 6 7]}) ({5 [1 2 3 4 6 7], 7 [5 3 4 6 1 2], 1 [7 2 3 4 5 6]})) However, when I try use this in a spec: (prop/for-all [bindings (gen/not-empty (gen-port-hierarchy))] (let [ ks (into #{} (keys bindings))] ...) I seem to be getting back a LazySeq which then leads to a ClassCastException: java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to java.util.Map$Entry Am I on the completely wrong path here? Or have I incorrectly hooked this generator up with test.check? Any help would be very appreciated. -- 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 -
Re: clojure.main on a clj file does not show up any println
That helped, Thanks! The Clojure CLR seems to be working a bit different. It insists on a ns, creates an exe by ns and its readily run-able. I gave Lein a shot too, but apparently its looking for some dependencies to be downloaded, I am behind a proxy so that dint work too... Is there a dependencies distrib i can download and place it? On Monday, December 8, 2014 7:32:16 PM UTC+5:30, Ganesh Krishnamoorthy wrote: I have been trying all my bit on to get my hello world working; Any help is much appreciated... am trying to run it by java -cp clojure-1.6.0.jar clojure.main hey.clj I just get an empty line. Below is my file: (defn -main [] (println Hello World!) (println (- 1 1))) -- 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.