Re: Faster JSON library
Clutch was mentioned a couple of times, so I figured I'd chime in. :-) As for why clutch uses c.c.json — I don't think there's any particular reason. Tunde chose it before I got involved, but I'm sure I probably would have done the same thing, mostly because JSON en/decoding speed isn't top-most on the performance priority list when you're IO-bound. Also, all things being equal, it's reasonable to use the 'blessed' library (an interesting topic/concept in and of itself). In any case, we'll probably be looking around at other options as we eliminate our last usages of classic contrib. (FYI, Clutch is 1.3-compatible even though it uses classic contrib.) Dave: I'm not sure if you were referring to me, but I have been working on supporting ClojureScript views in Clutch (which are working nicely now; blog post coming shortly). *Porting* Clutch to ClojureScript doesn't make a lot of sense to me, but that could easily just be me. (It's mostly interop, so it's not really a porting task, and I'm not too keen on clients touching my CouchDB instances directly in any case.) Cheers, - Chas On Oct 6, 2011, at 6:30 PM, Dave Sann wrote: In my opinion, the situation is not clear cut: I might want a slower but more portable library if porting clutch to clojurescript. (I read that someone has this working...) I might just want a lib that works if moving to .net in the short term but optimise with a faster library later. Or, I might want a fast JVM specific library Json parsing and writing has a relatively simple API/interface so different implementations of the same api are not unexpected. So I have two thoughts: 1. Assuming a standard API. How can you practically choose between different implementations that trade off different characteristics depending on your need. For example: performance vs portability; or performance on certain problem types vs others. 2. How many libraries might have a standard API with different implementations. (is it worth expending time to address this?) In general, this is a potentially tricky question in respect of dependency management. Cheers Dave -- 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 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
does clojurescript implement: list?
It seems not. I rummaged through the source and bootstrap.js and it does not seem to exist. Dave -- 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
Re: Faster JSON library
There was no particular reason to mention clutch. It was just the example that seemed to be in the discussion. Dave -- 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
Re: Faster JSON library
Sure, I wasn't attempting to be defensive or whatever. Just thought the perspective might be worthwhile. - Chas On Oct 7, 2011, at 12:55 AM, Dave Sann wrote: There was no particular reason to mention clutch. It was just the example that seemed to be in the discussion. Dave -- 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
Re: The Website / Wikispaces
Yes, and I also frequently get the Wikispaces homepage after hitting the browser's back button (while surfing through the pages at clojure.org). -- 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
Suggestion needed for namespace management in modular clojure app
Hi! I am working on a clojure app which needs to be modular. The module need to be pluggable. While I have figure out the pluggable part, I am facing issues with managing namespaces. I would prefer to have a modules directory where each module will create a sub directory and all files in the module sub directory expose a single namespace. The problem is even with AOT compile I am not able to achieve this. What I need is if the path of module subdirectory is xyz/modules/accounts teh namespace should be xyz.modules.accounts . How do I achieve this ? When ever I try to use AOT I get errors. Also, is there a better way to manage namespaces in modular applications. I do not want the developers of modules to struggle with managing files and namespaces. regards Vivek -- The hidden harmony is better than the obvious!! -- 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
Re: Reuse of generic Clojure/ClojureScript code?
Thanks Dave for sharing you current strategy for reusing generic Clojure/ClojureScript code. Have a look at the following dev thread where some ideas have been shared and feel free to comment: http://groups.google.com/group/clojure-dev/browse_thread/thread/831b74363da10187/3403e5ccbc488bc3 I haven't had much chance to take this further, however I will get back to it this coming week. -Alen On Oct 6, 4:06 am, Dave Sann daves...@gmail.com wrote: If anyone is interested, this is the strategy that I am currently using. It's a bit messy with linking but it saves me maintaining multiple versions and has worked so far. I expect that the linking could be removed with some work upstream. This is a workaround for me until a more standard solution comes out. I have started to separate code that I believe to be generic form code that I believe to be platform specific. It is not always possible to tell due to included dependencies, so there may be some trial and error. If I am making a project - say 'utils' that I think can be used across clj and cljs, I use the following structure: I put generic code in src. I put jvm specific code in src/utlis/x (namespace utils.x and below) I put cljs/js specific code in src_cljs/utils/x (namespace utils.x and below) Generic code is developed under src and sym-linked into src_cljs - with a change in extension to .cljs All platform dependent code is in or under the namespace utils.x (I use x because it's short and easy to see). This is not crosslinked (obviously). I do not use 'cljs' or 'jvm' as the name space for platform specific code. Using the same prefix 'x' allows generic code to freely use platform specific code provided that it is explicitly implemented to the same API in both clj and cljs. This may not always be a reasonable thing to do, but where it is it seems effective. Nothing special is required beyond this. I use cljs-watch to compile the clojurescript by pointing it at the src_cljs directory. Cheers Dave -- 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
Re: clojure.core.logic.core/match usage
Thanks David for fixing this so fast. It works very nicely... Sorry I couldn't reply sooner. Sunil. On Thu, Oct 6, 2011 at 8:15 AM, David Nolen dnolen.li...@gmail.com wrote: This should be fixed, I released 0.2.0-alpha4. Feedback appreciated. David. On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was playing with core.match library and I notice the following behavior let [x {:a 1 :b 2 :c 10 :d 30}] (match [x] [({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1 [({:a _ :b 2} :only [:a :b])] :a0 [{:a 1 :c _}] :a1 [{:c 3 :d _ :e 4}] :a2 :else [])) returns :a1 I was hoping to get :a-1 Am I using it wrong? Have I misunderstood as to how match is supposed to work? It looks like match assumes either that there is always a unique match or it does not guarantee that it will the try matches in the order specified. Can somebody help? Thanks, Sunil. -- 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 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 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
Re: clojure.core.logic.core/match usage
Turns out there was another edge case that I missed around :only which I've since fixed in master. Once I resolve MATCH-26 I'll cut another alpha release. David On Fri, Oct 7, 2011 at 11:55 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David for fixing this so fast. It works very nicely... Sorry I couldn't reply sooner. Sunil. On Thu, Oct 6, 2011 at 8:15 AM, David Nolen dnolen.li...@gmail.comwrote: This should be fixed, I released 0.2.0-alpha4. Feedback appreciated. David. On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was playing with core.match library and I notice the following behavior let [x {:a 1 :b 2 :c 10 :d 30}] (match [x] [({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1 [({:a _ :b 2} :only [:a :b])] :a0 [{:a 1 :c _}] :a1 [{:c 3 :d _ :e 4}] :a2 :else [])) returns :a1 I was hoping to get :a-1 Am I using it wrong? Have I misunderstood as to how match is supposed to work? It looks like match assumes either that there is always a unique match or it does not guarantee that it will the try matches in the order specified. Can somebody help? Thanks, Sunil. -- 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 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 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 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
Re: The Website / Wikispaces
Me too. -- 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
Re: Faster JSON library
My 2 cents: 1. JSON transformation is of fundamental importance to many Clojure applications. 2. Having the standard solution be blown away by a factor of 140x for the sake of purity is not pragmatic. If the user experience with contrib is to use it, realize its not ready for prime time, and then go rummaging around through github for better solutions made by people who've previously realized the same thing, that is a fail. And makes one less likely to look to contrib for default solutions to common problems. On Thu, Oct 6, 2011 at 11:03 AM, Lars Nilsson chamael...@gmail.com wrote: The clojure.contrib.base64 discussion has inspired me (sorry!) to write this.. I would very much like to see a faster JSON parser be in contrib. clj-json can beat clojure.data.json by up to a factor of 140x when reading/parsing and 5x when creating a JSON string. clojure.data.json reading: (dotimes [_ 5] (time (read-json (slurp foo.json Elapsed time: 105137.039484 msecs Elapsed time: 109517.590644 msecs Elapsed time: 114940.018075 msecs Elapsed time: 107612.194846 msecs Elapsed time: 104434.230607 msecs nil clj-json reading: (dotimes [_ 5] (time (parse-string (slurp foo.json) true))) Elapsed time: 851.541746 msecs Elapsed time: 716.894466 msecs Elapsed time: 713.257132 msecs Elapsed time: 710.379671 msecs Elapsed time: 709.358592 msecs nil clojure.data.json create string: (def foo (read-json (slurp foo.json))) (dotimes [_ 5] (time (json-str foo))) Elapsed time: 1546.511918 msecs Elapsed time: 1533.056017 msecs Elapsed time: 1534.136322 msecs Elapsed time: 1537.893503 msecs Elapsed time: 1555.343765 msecs nil clj-json create string: (def foo (parse-string (slurp foo.json))) (dotimes [_ 5] (time (generate-string foo))) Elapsed time: 375.415311 msecs Elapsed time: 298.440444 msecs Elapsed time: 272.829368 msecs Elapsed time: 271.800466 msecs Elapsed time: 273.67808 msecs nil The JSON file is about 217KB, with vectors containing a couple of thousand JSON objects with nested vector objects between 2-6 levels deep. Granted, clj-json uses a (presumably heavily optimized) Java library as the work horse, while clojure.data.json is pure Clojure. However, I feel the speed penalty is too big of a price to pay in this case. Now, I can use clj-json for my own parsing needs. However, something like clutch (couchdb library) that uses c.d.json behind the scenes may be paying a price in performance that I cannot easily overcome without hacking around inside it in order to swap JSON implementation, rather than tweaking my own code (although, in this case it may be limited to just the JSON string creation). Perhaps there are benefits (of which I'm not aware) to c.d.json that are not available in clj-json, but I'd be hard-pressed to come up with a scenario where I wouldn't pick the significant speed boost of clj-json. Lars Nilsson -- 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 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
Re: Faster JSON library
Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). Lars Nilsson -- 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
Re: Faster JSON library
Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). Lars Nilsson Thanks. I am going to take a look at this now. Stu Stuart Halloway Clojure/core http://clojure.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
Re: Faster JSON library
That would be http://dev.clojure.org/jira/browse/DJSON-1 which I opened at the end of July... On Fri, Oct 7, 2011 at 11:10 AM, Lars Nilsson chamael...@gmail.com wrote: Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). -- 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
Re: Faster JSON library
As long as we're fixing d.c.json... it would be nice to add support for encoding sequences and maps. (I know, I should open a bug) On 10/07/2011 02:04 PM, Sean Corfield wrote: That would be http://dev.clojure.org/jira/browse/DJSON-1 which I opened at the end of July... On Fri, Oct 7, 2011 at 11:10 AM, Lars Nilsson chamael...@gmail.com wrote: Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the "let" to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). -- 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
Re: Faster JSON library
I get the following, trying to follow that link. Login Required You are not logged in. You cannot view this URL as a guest. You must log in or sign up for an account . If you think this message is wrong, please consult your administrators about getting the necessary permissions. Lars Nilsson On Fri, Oct 7, 2011 at 3:04 PM, Sean Corfield seancorfi...@gmail.com wrote: That would be http://dev.clojure.org/jira/browse/DJSON-1 which I opened at the end of July... On Fri, Oct 7, 2011 at 11:10 AM, Lars Nilsson chamael...@gmail.com wrote: Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). -- 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 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
Re: Faster JSON library
Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). Lars Nilsson This reflection warning can be fixed with an enhancement on the Clojure side, which I have just pushed to master [1]. I would like to create 1.4 alpha 1 with the code changes that have gone in today. It would be super-great if anybody has time to build your own project against master and let us know if you see any issues. Thanks, Stu [1] https://github.com/clojure/clojure/commit/405d24dd49d649c01b7881f1394fc90924c54ef0 -- 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
How to use realized? on a lazy sequence?
Here's a REPL session, wherein I try to use realized? on a lazy-seq. Clojure 1.3.0 Define the lazy-seq: user= (def naturals (iterate inc 0)) #'user/naturals Force realization of the first 1 + 123456 elements: user= (time (nth naturals 123456)) Elapsed time: 481.349 msecs 123456 Due to previous realization, the same expression now eval's quickly: user= (time (nth naturals 123456)) Elapsed time: 15.571 msecs 123456 Now I try to use realized? on 123456th element: user= (realized? (nth naturals 123456)) ClassCastException java.lang.Long cannot be cast to clojure.lang.IPending clojure.core/realized? (core.clj:6505) Ouch! I guess realized? isn't a macro. Next try: user= (realized? (drop 123456 naturals)) false Hmmm... could I be off by one? Let's leave lots of room for error: user= (realized? (drop 12345 naturals)) false user= (realized? (drop 0 naturals)) false Huh? How do I get realized? to tell me what I want to know? What I want to know, is wether the element at the nth index has been computed and cached. Maybe something like realized- length, just for lazy-seq's, which would report how far along the sequence has realization occurred. Thanks, George Kangas -- 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
Re: Faster JSON library
seems like that could be added to Intrinsics.java On Fri, Oct 7, 2011 at 1:20 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: Trying to be a little bit constructive here, in case I come across as complaining, I took the source for c.d.json and put it into a leiningen project, enabled warn on reflection, and found that several cases of (... (let [c (char i] ... (= c \x) ...) results in Clojure deciding it needs to perform reflection in order to call equals in the comparison with a fixed character. I'm not really sure what the proper solution for this is, but I changed the let to (let [c (Character/valueOf (char i)] ...) and the time for my 217KB JSON file dropped from 107 seconds to 2 seconds, or only a little more than twice as slow as clj-json (which clocked in a little under one second for my file). Lars Nilsson This reflection warning can be fixed with an enhancement on the Clojure side, which I have just pushed to master [1]. I would like to create 1.4 alpha 1 with the code changes that have gone in today. It would be super-great if anybody has time to build your own project against master and let us know if you see any issues. Thanks, Stu [1] https://github.com/clojure/clojure/commit/405d24dd49d649c01b7881f1394fc90924c54ef0 -- 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 -- And what is good, Phaedrus, And what is not good— Need we ask anyone to tell us these things? -- 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
Re: How to use realized? on a lazy sequence?
George Kangas gwkan...@gmail.com writes: Now I try to use realized? on 123456th element: user= (realized? (nth naturals 123456)) ClassCastException java.lang.Long cannot be cast to clojure.lang.IPending clojure.core/realized? (core.clj:6505) Hm, that's strange indeed. I also get user (realized? (iterate int 0)) ;clojure.lang.Cons cannot be cast to clojure.lang.IPending ; Evaluation aborted. where I'd expect it to return false. However, it works just fine with `range' in place of iterate: user (realized? (range 0 10)) false user (realized? (doall (range 0 10))) true Bye, Tassilo Ouch! I guess realized? isn't a macro. Next try: No, it's a function. But why should that be important. Ok, before a funcall all args are evaluated, but the result of evaluating a lazy seq is still the same lazy seq. Evaluation doesn't realize anything, only calling first/rest on the seq does. Huh? How do I get realized? to tell me what I want to know? What I want to know, is wether the element at the nth index has been computed and cached. Ditto. Bye, Tassilo -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to use realized? on a lazy sequence?
Can't you write that function yourself? (defn realized-length [xs] (loop [n 0 xs xs] (if (realized? xs) (recur (inc n) (rest xs)) n))) drop returns a new lazy sequence, with no realized elements, so naturally you can't ask if the sequence under it is realized. If you want to work at such a low level you can't build a new lazy sequence; the above avoids that problem by working with the sequence primitives. user= (def naturals (rest (iterate inc 0))) #'user/naturals user= (realized-length naturals) 0 user= (take 10 naturals) (1 2 3 4 5 6 7 8 9 10) user= (realized-length naturals) 10 Note that this does not work for the base case of an iterated sequence, because that is not a lazy-seq but a cons. Seems a bit weird to me, but then realized? itself is a bit weird... On Oct 7, 1:46 pm, George Kangas gwkan...@gmail.com wrote: Here's a REPL session, wherein I try to use realized? on a lazy-seq. Clojure 1.3.0 Define the lazy-seq: user= (def naturals (iterate inc 0)) #'user/naturals Force realization of the first 1 + 123456 elements: user= (time (nth naturals 123456)) Elapsed time: 481.349 msecs 123456 Due to previous realization, the same expression now eval's quickly: user= (time (nth naturals 123456)) Elapsed time: 15.571 msecs 123456 Now I try to use realized? on 123456th element: user= (realized? (nth naturals 123456)) ClassCastException java.lang.Long cannot be cast to clojure.lang.IPending clojure.core/realized? (core.clj:6505) Ouch! I guess realized? isn't a macro. Next try: user= (realized? (drop 123456 naturals)) false Hmmm... could I be off by one? Let's leave lots of room for error: user= (realized? (drop 12345 naturals)) false user= (realized? (drop 0 naturals)) false Huh? How do I get realized? to tell me what I want to know? What I want to know, is wether the element at the nth index has been computed and cached. Maybe something like realized- length, just for lazy-seq's, which would report how far along the sequence has realization occurred. Thanks, George Kangas -- 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
Re: clojure.core.logic.core/match usage
Thanks David, Although not related to core.match, I was playing with your core.logic, I found that there was no condi (there were only conde condu and conda) .. Is it just left as a future thing? Sunil. On Fri, Oct 7, 2011 at 9:34 PM, David Nolen dnolen.li...@gmail.com wrote: Turns out there was another edge case that I missed around :only which I've since fixed in master. Once I resolve MATCH-26 I'll cut another alpha release. David On Fri, Oct 7, 2011 at 11:55 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David for fixing this so fast. It works very nicely... Sorry I couldn't reply sooner. Sunil. On Thu, Oct 6, 2011 at 8:15 AM, David Nolen dnolen.li...@gmail.comwrote: This should be fixed, I released 0.2.0-alpha4. Feedback appreciated. David. On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was playing with core.match library and I notice the following behavior let [x {:a 1 :b 2 :c 10 :d 30}] (match [x] [({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1 [({:a _ :b 2} :only [:a :b])] :a0 [{:a 1 :c _}] :a1 [{:c 3 :d _ :e 4}] :a2 :else [])) returns :a1 I was hoping to get :a-1 Am I using it wrong? Have I misunderstood as to how match is supposed to work? It looks like match assumes either that there is always a unique match or it does not guarantee that it will the try matches in the order specified. Can somebody help? Thanks, Sunil. -- 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 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 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 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 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
Re: How to use realized? on a lazy sequence?
On Oct 7, 5:02 pm, Alan Malloy a...@malloys.org wrote: Can't you write that function yourself? (defn realized-length [xs] (loop [n 0 xs xs] (if (realized? xs) (recur (inc n) (rest xs)) n))) Thanks, Alan! drop returns a new lazy sequence, with no realized elements, I didn't realize that! I expected that drop would call rest recursively, like your realized-length does. But apparently, it's lazier than that: user= (def c (drop 12345678 naturals)) #'user/c user= (time (first c)) Exception in thread main java.lang.OutOfMemoryError: Java heap space (more java.lang.barfing) user= (def naturals (rest (iterate inc 0))) #'user/naturals You introduce another subtlety here: realized? won't work on the result of iterate (as Tassilo Horn found), but it will work on (rest (iterate ...)). And this is because: Note that this does not work for the base case of an iterated sequence, because that is not a lazy-seq but a cons. Seems a bit weird to me, but then realized? itself is a bit weird... realized? doesn't seem so weird, when it deals with promises, delays and futures. Those objects have explicit API's for their creation and realization, and realized? has a natural and predictable role in that API. Lazy sequences are more magic, and less explicit about creation and realization (or so it seems to me). Implementors of functions such as iterate, drop, rest, range, etc., have some freedom to decide times of creation/realization. Then, when you try to use realized? on lazy sequences, those decisions (which you may not have expected) come to the surface. Maybe realized? doesn't really belong in the lazy sequence API, but it is fun to play around with it. Thanks for showing me how! regards, George -- 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
Re: clojure.core.logic.core/match usage
Hi Sunil, core.logic's conde is condi, there is no equivilant to TRS's conde in core.logic. Thanks, Ambrose On Sat, Oct 8, 2011 at 10:08 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David, Although not related to core.match, I was playing with your core.logic, I found that there was no condi (there were only conde condu and conda) .. Is it just left as a future thing? Sunil. On Fri, Oct 7, 2011 at 9:34 PM, David Nolen dnolen.li...@gmail.comwrote: Turns out there was another edge case that I missed around :only which I've since fixed in master. Once I resolve MATCH-26 I'll cut another alpha release. David On Fri, Oct 7, 2011 at 11:55 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David for fixing this so fast. It works very nicely... Sorry I couldn't reply sooner. Sunil. On Thu, Oct 6, 2011 at 8:15 AM, David Nolen dnolen.li...@gmail.comwrote: This should be fixed, I released 0.2.0-alpha4. Feedback appreciated. David. On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was playing with core.match library and I notice the following behavior let [x {:a 1 :b 2 :c 10 :d 30}] (match [x] [({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1 [({:a _ :b 2} :only [:a :b])] :a0 [{:a 1 :c _}] :a1 [{:c 3 :d _ :e 4}] :a2 :else [])) returns :a1 I was hoping to get :a-1 Am I using it wrong? Have I misunderstood as to how match is supposed to work? It looks like match assumes either that there is always a unique match or it does not guarantee that it will the try matches in the order specified. Can somebody help? Thanks, Sunil. -- 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 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 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 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 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 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
Re: clojure.core.logic.core/match usage
There is no conde as defined in The Reasoned Schemer in core.logic. conde in core.logic is condi. David On Friday, October 7, 2011, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David, Although not related to core.match, I was playing with your core.logic, I found that there was no condi (there were only conde condu and conda) .. Is it just left as a future thing? Sunil. On Fri, Oct 7, 2011 at 9:34 PM, David Nolen dnolen.li...@gmail.com wrote: Turns out there was another edge case that I missed around :only which I've since fixed in master. Once I resolve MATCH-26 I'll cut another alpha release. David On Fri, Oct 7, 2011 at 11:55 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Thanks David for fixing this so fast. It works very nicely... Sorry I couldn't reply sooner. Sunil. On Thu, Oct 6, 2011 at 8:15 AM, David Nolen dnolen.li...@gmail.com wrote: This should be fixed, I released 0.2.0-alpha4. Feedback appreciated. David. On Mon, Oct 3, 2011 at 6:27 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hello everybody, I was playing with core.match library and I notice the following behavior let [x {:a 1 :b 2 :c 10 :d 30}] (match [x] [({:a _ :b _ :c _ :d _} :only [:a :b :c :d])] :a-1 [({:a _ :b 2} :only [:a :b])] :a0 [{:a 1 :c _}] :a1 [{:c 3 :d _ :e 4}] :a2 :else [])) returns :a1 I was hoping to get :a-1 Am I using it wrong? Have I misunderstood as to how match is supposed to work? It looks like match assumes either that there is always a unique match or it does not guarantee that it will the try matches in the order specified. Can somebody help? Thanks, Sunil. -- 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 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 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+unsubscribe -- 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 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
Re: when does one prefix the symbolnames with '?' when used in core.logic goals..
Hi Sunil, For a more detailed tutorial on matche, search for matche on this page: https://github.com/frenchy64/Logic-Starter/wiki/Introduction-to-Logic-Programming-with-Clojure Thanks, Ambrose On Sat, Oct 8, 2011 at 10:20 AM, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Hi, I was looking through the core.logic readme file. I notice that the var-names (symbols) are prefixed with '?' at some locations and they are not at some other locations. Can somebody help me figure this out. Please look at the readme file found at https://github.com/clojure/core.logic (use '[clojure.core.logic minikanren prelude nonrel match]) (defna findo [x l o] ([_ [[?y :- o] . _] _] (project [x ?y] (== (= x ?y) true))) ([_ [_ . ?c] _] (findo x ?c o))) (defn typedo [c x t] (conda((lvaro x) (findo x c t))((matche [c x t] ([_ [[?x] : ?a] [?s : ?t]] (fresh [l](conso [?x :- ?s] c l)(typedo l ?a ?t))) ([_ [:apply ?a ?b] _] (fresh [s](typedo c ?a [s : t])(typedo c ?b s))) I tried to look for similar stuff in the core.match libraries but could not.. Thanks, Sunil. -- 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 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
error on compile
Hi! When I try to compile a class from repl I am getting following error user= (compile 'xyz.modules.accounts.accounts) java.lang.ClassNotFoundException: clojure.contrib.json.Read_JSON_From (json.clj:167) I have tried searching the docs but I cant find clojure.contrib.json.Read_JSON_From anywhere . Is it some dependancy that I am missing ? I am using clojure 1.2.0 and clojure.contrib 1.2.0 . regards Vivek -- 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
Re: error on compile
Without actually seeing the code, only guess I can make is that you are probably using vars with underscores in them. While I do not know for sure that it is not allowed, I do know that they are typically avoided. Usually, I think, something like read-json-from gets internaly converted to read_json_from This is just guess. If you post more code, it is easier to help. Sunil. On Sat, Oct 8, 2011 at 10:07 AM, Vivek Khurana hiddenharm...@gmail.comwrote: Hi! When I try to compile a class from repl I am getting following error user= (compile 'xyz.modules.accounts.accounts) java.lang.ClassNotFoundException: clojure.contrib.json.Read_JSON_From (json.clj:167) I have tried searching the docs but I cant find clojure.contrib.json.Read_JSON_From anywhere . Is it some dependancy that I am missing ? I am using clojure 1.2.0 and clojure.contrib 1.2.0 . regards Vivek -- 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 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