Re: Baltimore Functional Programming
I'm also interested. I just started to go to beehive occasionally and I was recently discussing with someone how it would be nice to have a FP group. I live in Federal Hill. On Nov 30, 11:09 am, Gary Trakhman gary.trakh...@gmail.com wrote: Awesome, so it looks like there will be enough people to make this happen. I've been in touch with beehive about using their space. I'm considering whether or not to use meetup.com to organize everything, but I think for now I'll put together a simple wordpress/google-groups thing and follow-up with you guys. Also, if anyone has any leads on a meeting space, I can offer a projector. -- 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: Erlang/OTP in clojure
Ole, Glad you liked my posts on Riak. I took a quick glance at your code and it's amazing how much Clojure I've forgotten over the last year. I need to read my Joy of Clojure :) If you're looking for Erlang/OTP in Clojure land than I think an easier path might be to look at Erjang [1]. AFAICT, it is a fairly solid implementation of Erlang/OTP, is in active development, and has some really smart devs behind it. -Ryan [1]: https://github.com/trifork/erjang/wiki On Aug 12, 1:32 pm, Ole Rixmann rixmann@googlemail.com wrote: Hi everyone, i just read this series of posts about riak corehttps://github.com/rzezeski/try-try-try. I liked it (because i did a lot Erlang recently) and wanted to have a similar thing in clojure. So i started, although i know i would need years to build such a system on my own, but a gen_server would be nice ;). Here is my first approach to a fsm: git repo:https://github.com/rixmann/gen_fsm clojars: [org.clojars.owl/gen_fsm 0.1-BETA] If you are interested please tell me what to do better or contribute :-). Greetings, Ole -- 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 script in the classpath
On Jun 18, 6:15 pm, Paul Moore p.f.mo...@gmail.com wrote: I've just seen a couple of postings which, if I'm not mistaken, imply that it's possible to have a Clojure script in my classspath. Is that right? Yes, you can have .clj files on your classpath. In fact, you can pretty much have anything on your classpath. Checkout java.lang.ClassLoader http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html#getResource(java.lang.String) . This is what Clojure uses under the covers. Can anyone give me a complete example of how this works? (I probably need to get the file names and namespaces right, something I'm still struggling with - again the Java/JVM requirements for filenames that match classnames is a new concept for me). Let's say I put my clojure.jar on the classpath, but only put the clojure-contrib source files on the classpath and I want to use the clojure.contrib.string/blank? function. Here is a session at the REPL. Note that I used a custom script to start the REPL, it prints out the Java executable and CLASSPATH env variable at the top. rzeze...@chinaski.local [~] clojure JAVA: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java CLASSPATH: /Users/rzezeski/projects/clojure/clojure.jar:/Users/rzezeski/projects/clojure-contrib/src/main/clojure Clojure 1.2.0-master-SNAPSHOT user= (clojure.contrib.string/blank? ) java.lang.ClassNotFoundException: clojure.contrib.string (NO_SOURCE_FILE:0) user= (load /clojure/contrib/string) nil user= (clojure.contrib.string/blank? ) true user= Notice the load function converted my string into a path to the .clj I wanted. The initial forward-slash means I want to lookup relative to the classpath. The lib I want has the namespace clojure.contrib.string. In this case simply convert the periods to forward-slashes. You don't specify the .clj extension because Clojure will first try to load the lib via class file or source depending on which is newer. For example, if I tried to load the lib foo.bar. user= (load /foo/bar) java.io.FileNotFoundException: Could not locate foo/bar__init.class or foo/bar.clj on classpath: (NO_SOURCE_FILE:0) Now that I've shown you the load function I'm going to pull the rug from underneath you and tell you not to use it to load your Clojure libraries. The idiomatic way to load a lib is via the require function, which uses load under the covers. Require allows you to specify your lib in it's native Clojure tongue. user= (require '[clojure.contrib.repl-utils :as ru]) nil user= (ru/show ClassLoader) === public abstract java.lang.ClassLoader === [ 0] static getSystemClassLoader : ClassLoader () [ 1] static getSystemResource : URL (String) ... HTH, -Ryan -- 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: classpath and require
On Jun 18, 5:00 pm, Mohammad Khan beepl...@gmail.com wrote: C:\Projects.cljjava -cp c:\clojure-contrib\clojure-contrib.jar;c:\clojure\clojure.jar clojure.main Clojure 1.1.0-alpha-SNAPSHOT user= (require 'examples.introduction) java.io.FileNotFoundException: Could not locate examples/introduction__init.class or examples/introduction.clj on classpath: (NO_SOURCE_FILE:0) user= C:\Projects.cljecho %CLASSPATH% C:\Projects.clj;C:\clojure;C:\clojure-contrib C:\Projects.cljdir examples\introduction.clj Volume in drive C is xxx Volume Serial Number is - Directory of C:\Projects.clj\examples 06/18/2010 04:52 PM 40 introduction.clj 1 File(s) 40 bytes 0 Dir(s) xx,xxx,xxx bytes free C:\Projects.clj You're overriding your %CLASSPATH% variable with your -cp argument [1]. Try starting your REPL with the following. java -cp c:\clojure-contrib\clojure-contrib.jar;c:\clojure \clojure.jar;C:\Projects.clj clojure.main 1: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/java.html#options -- 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: Basic toolset for non-Java programmer
While not reflective of the entire community, here's my suggestions. - Build tools: There seem to be things like ant, maven, leiningen. How do they relate to each other? Is there an obvious best answer or should I be expecting to check them all out depending on my needs? In that case, are there any good comparisons around? Honestly, for now, I would either go with Leiningen or Maven, with Leiningen probably having the most gentle learning curve. In the long run, I don't think there is a clear best answer, yet. - Debuggers: Should I be assuming I use my IDE for debugging? What if I stick to a basic text editor to develop my code? Is there a good standalone debugger? You can use standard Java debuggers with your Clojure app. I won't pretend to be well versed in the practice, but I've tried it a few times with a few different debuggers with varying degrees of success. If you like Emacs, my best experience was with this: http://georgejahad.com/clojure/cljdb.html. Note that this just uses jdb under covers, jdb is java's bundled debugger. It's primitive, but it works. - Profilers: Same sort of question - do IDEs offer this, are there standalone tools? You can start with the bundled profiler, jvisualvm. I've used it a couple of times to track down performance bottlenecks and I felt it worked well. You can also get a trial of YourKit, but I've read from some that it's overpriced for what you get. - Testing: I've not really got to the documentation on Clojure's own testing tools, so maybe that's all I need, but are there testing frameworks I should look at, that sort of thing? http://richhickey.github.com/clojure/clojure.test-api.html That should have everything you need to get started. - Deployment: For simple standalone utilities, am I looking at bat file wrappers (I'm on Windows mainly) to set classpath and the like? Given that there are some annoying limitations with bat files (nasty nesting behaviour, ugly console windows for GUI applications), are there any commonly used better solutions? For web applications, I gather that a servlet container (all that fancy J2EE stuff :-)) and something like compojure is a good place to start. For non-web long-running services, is it still reasonable to use an application server, or should I be looking at something to wrap a Clojure app up as a Windows service (something like Java Service Wrapper (http://wrapper.tanukisoftware.org/doc/english/download.jsp) came up for me on a Google search)? For a webapp built with Compojure you can build a WAR and deploy it on any J2EE container. Probably the most convenient model. For a standalone app you could build what we call an uberjar (a JAR with all your dependencies) and write a small script to execute your main entry point. Once again, if you're an Emacs person you may want to start up a swank server in your entry point to allow for remote debugging and hot-patching. I'm sure others will have much to add, but this should be a start. HTH -Ryan -- 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: Passing Arguments From Java to Clojure
-- CallClojure.java -- import clojure.lang.RT; import clojure.lang.Var; import clojure.lang.PersistentVector; public class CallClojure { static PersistentVector toVec(int[][] arr) { PersistentVector pv = PersistentVector.EMPTY; for (int[] a : arr) { PersistentVector temp = PersistentVector.EMPTY; for (int n : a) { temp = temp.cons(n); } pv = pv.cons(temp); } return pv; } public static void main(String[] args) throws Exception { RT.loadResourceScript(foo.clj); Var gimmie_vec = RT.var(foo, gimmie-vec); int[][] ar = {{1, 2}, {3, 4}, {5, 6}}; Object result = gimmie_vec.invoke(toVec(ar)); System.out.println(result); } } -- foo.clj -- (ns foo) (defn gimmie-vec [v] (println class: (class v)) (println v: v)) -- 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
bit-and reflection warning
When using bit-and with longs I get a reflection warning. How can I make this go away? user (bit-and (long -10) 0x) Reflection warning, NO_SOURCE_FILE:1 - call to and can't be resolved. 4294967286 -- 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: apply with constructors
Can you let the fn call figure that out for you? Like so: (apply (fn ([p1 p2] (new Connection.Configuration p1 p2)) ([p1 p2 p3] (new Connection.Configuration p1 p2 p3))) params) I realize that reflection is probably better in this case, but was wondering if this would work. Seems it would. user (apply (fn ([ch] (String. ch)) ([ch off len] (String. ch off len))) [(char-array [\r \y \a \n])]) ryan user (apply (fn ([ch] (String. ch)) ([ch off len] (String. ch off len))) [(char-array [\r \y \a \n]) 0 2]) ry -- 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: bit-and reflection warning
I was able to make this go away by adding a method to Numbers.java. I have a use case where I'm calling bit-and with two longs tens of millions of times. Is there another way I could avoid this reflection without this change to the Java source? diff --git a/src/jvm/clojure/lang/Numbers.java b/src/jvm/clojure/lang/ Numbers.java index 2aaabee..051 100644 --- a/src/jvm/clojure/lang/Numbers.java +++ b/src/jvm/clojure/lang/Numbers.java @@ -1880,6 +1880,10 @@ static public int and(int x, int y){ return x y; } +static public long and(long x, long y){ + return x y; +} + static public int or(int x, int y){ return x | y; } -- 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: Some basic guidance to designing functional vs. state parts of app
On Mar 2, 11:34 pm, Sophie itsme...@hotmail.com wrote: How do I choose? What are the trade-offs? Any and all guidance, insights, advice etc. welcome! Thanks! To me, it seems like you have two orthogonal pieces of data, and a function that builds a report from that data. You have a set of job listings, and a set of applicants. I see no reason why these need to be coordinated (ref). The addition of a job listing is totally independent of an applicant updating her resume. So it's uncoordinated (atom). That is, the job listings are always in a consistent state no matter what I do to the applicant data. Said another way, there's nothing I can do to the applicant data that can put the job listings in an inconsistent state. As for the match function. Well it needs to get a snapshot of both pieces of data, and then determine what applicants match up with each job listing. While this function is running a job could be added, an applicant could update her resume, or maybe an applicant will remove her resume but your function won't see any of that, but who cares? It will see a consistent snapshot of both pieces of data, and from those it will build the result. As of time T1, here is your latest and greatest match report. Now, say you want the match report built every time a job listing or applicant data is changed. This way the 'latest' report is always in memory and ready to go. Well, in this case, you now need to coordinate the update of job listings or applicant data with the generation of the report. You never want your program to enter a state where the job listings are in state L101 and applicants are in state A54 and your report is based on the combination of (L101, A53). That's an inconsistent state because your report is not based on the latest data. In this case, you'd probably want to use refs to make sure the your job/applicant data is coordinated with your report data. However, if your data is constantly changing, and the match function takes a while to run then this may be very slow. Take what I say with a grain of salt as I'm also fairly new to this stuff. At the end of the day, experience is probably the best teacher. -- 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: more lazy fun
On Jan 28, 3:26 pm, Raoul Duke rao...@gmail.com wrote: [gmail is freaking out, apologies if this is sent twice] On Thu, Jan 28, 2010 at 12:23 PM, DanL leidis...@gmail.com wrote: When exactly would a lazy sequence evaluate to false? i thought it was happening with code like: (let [final-answer (and (map #(= foo %) [foo bar]))] (if final-answer yay humbug)) in a larger routine. it wasn't doing what i expected from my tests, and when i put in a println then it suddenly worked. which led me to figure it was something about laziness. changing the if to read (if (vec final-answer) ...) fixed it. ? Raoul, I think if you evaluate this code piece-by-piece the behavior will become more clear. From your example I feel like you are trying to determine if all elements in a given collection/sequence are of the value foo? Start from the inside and work your way out. user (map #(= foo %) [foo bar]) (true false) So here we returned a lazy seq of boolean values based on the anonymous function being used as a predicate. user (and (map #(= foo %) [foo bar])) (true false) Now we pass the result to and, but yet the same result is returned. From what I can tell you expected and to make sure all values in this sequence were true, but lets look at the doc string. user (doc and) - clojure.core/and ([] [x] [x next]) Macro Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and doesn't evaluate any of the other expressions, otherwise it returns the value of the last expr. (and) returns true. nil Notice that and is a macro and that it doesn't expect a sequence as argument, but rather 0 to multiple expressions (also note that the doc string appears to have a typo or some sort). So the seq you passed and is treated as one expression, and that expression is treated as true, and it is the last expression so it is returned. To summarize, the and function simply returned the same exact sequence that it was passed in the first place. The reason yay is returned is because a seq will evaluate to true. user (if '(true false) yay humbug) yay user (if '() yay humbug) yay user (if '(nil) yay humbug) yay user (if nil yay humbug) humbug I'm not sure how calling vec on final-answer fixed your problem unless there is some code you are not showing. user (if (vec '(true false)) yay humbug) yay user (if (vec '()) yay humbug) yay user (if (vec nil) yay humbug) yay However, the following will work. user (every? (partial = foo) [foo bar]) false I think the problem was more of a misunderstanding with the and function and not lazy sequences. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: strange typecheck error
On Dec 30, 12:53 pm, Alex Ott alex...@gmail.com wrote: If need, i can submit somebody full test case I think this might help because it's hard to tell what you are trying to do without a little more context. Some odd things that stand out to me: 1) You call loop, but you should be calling recur. E.g. (loop result) 2) Why are the arguments streams and not readers? 3) You do nothing with the 'char' variable binding. My guess is you just made some typos while trying to create a simple example. -- 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: Web application framework (beta)
I'm not privy to all the technical details, but perhaps work done on Swarm could be insightful? http://code.google.com/p/swarm-dpl/ -- 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: Space leak with lazy sequences.
I'm having similar problems, but am hesitant to post until I do some further analysis. However, I thought I'd share some techniques I'm trying to use to hunt down my memory leak. First, you can make GC verbose. -verbose:gc For even more detail, add the following. -XX:+PrintGCTimeStamps -XX:+PrintGCDetails. Second, do a heap dump. If you are using Java 6 then you can use the jmap tool. jmap -dump:live,format=b,file=foo.hprof PID Once you have the heap dump you can use the Eclipse Memory Analyzer Tool. It can take your heap dump and create various reports. One of them being a dominator tree which will show you what object has the largest retained heap size. I'm still a complete novice with it, but it already helped me track down some memory leaks at work. Check out this article, goes over what I just said and much more. http://olex.openlogic.com/wazi/2009/how-to-fix-memory-leaks-in-java/ . -- 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 is two!
On Oct 16, 12:12 pm, Rich Hickey richhic...@gmail.com wrote: http://clojure.blogspot.com/2009/10/clojure-is-two.html Thanks again to all! Rich Stu Halloway's terrific book, and more books on the way Can anyone elaborate on this? --~--~-~--~~~---~--~~ 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: immutable defs?
On Oct 2, 11:52 am, Mark Tomko mjt0...@gmail.com wrote: However, outside the scope of a function, it seems that it's possible for bindings to be redefined later in a file without causing an immediate error. This could easily lead to mistakes that would manifest as silent and potentially inexplicable behavior later. There is a reason def can mutate things at the global root. See 2:24:00 of the Clojure Concurrency screencast [1]. Basically, you need this ability in order to fix/change programs without restarting them. 1: http://clojure.blip.tv/file/812787/ --~--~-~--~~~---~--~~ 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: Enlive questions
On May 6, 1:36 am, Christophe Grand christo...@cgrand.net wrote: Hello Ryan, rzeze...@gmail.com a écrit : Either I've missed something, orEnlive*appears* to have problems handling comment tags. Indeed. I pushed a fix, please tell me whether it works for you now. Thanks for the report. Christophe -- Professional:http://cgrand.net/(fr) On Clojure:http://clj-me.blogspot.com/(en) Works fine now. Thanks for the quick response, and for Enlive! --~--~-~--~~~---~--~~ 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 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: Enlive questions
Either I've missed something, or Enlive *appears* to have problems handling comment tags. I was using Enlive against an already existing HTML file and kept getting the following exception (please note it is HTML 4.01 Strict and passed validation): java.lang.RuntimeException: java.lang.IllegalArgumentException: Don't know how to create ISeq from: Keyword The following should reproduce: (def res (html-resource (java.io.StringReader. htmlbodyh1/ h1!-- oh noes, a comment --/body/html))) I don't have time to track down the problem any further, if it is a problem and not something stupid on my part. Thanks, Ryan --~--~-~--~~~---~--~~ 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 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 Path to 1.0
As with any decision, it will be impossible to please everyone. I think the Git vs Subversion talk is way off topic at this point, but to each his own. Rich, I think it really depends on what *YOU* want Clojure to be. If you want to take a Haskell like approach and avoid success at all costs then I would delay 1.0 for as long as possible. However, if you want to bring on wide adoption, which I think you do, then I think it is *IMPERATIVE* that the front of Stu's book includes the text Works for Clojure 1.0. It is my opinion that if Programming Clojure goes to print without that text Clojure, as a community and a language, loses a lot of potential users! It isn't a big deal to bleeding-edge folks like ourselves, but we are a *MINORITY*. And a minority is all we will be if we think in minor terms. I agree with a lot of what has been said here, but I feel Stu's book release should be at the top of the list. It's Clojure's first impression on the global community of developers, and we all know the rule about first impressions. I vote pragmatism, lets get this sucker rolling! -Ryan --~--~-~--~~~---~--~~ 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 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: Contribs with dependencies
My .02 cents... I always viewed Contrib as an incubator of sorts for Core. That it was simply a testing ground for functionality that *MIGHT* make it into Core if enough people find it useful, or Rich hands down his good graces. Requiring a few external libs here and there, and breaking Contrib up into modules may sound simple to some, but I think your quickly forgetting the additional cognitive load of such a decision. If we go the simple route and just require the user to download the libs, then it starts out all well and good, but will quickly turn into dependency hell. Anyone whose been using Linux long enough, or still uses a distro like Slackware knows exactly what I'm talking about. IMO, this is just *NOT* and option. If we create some build or module system around Contrib, we alleviate the dependency problem, but add complexity to the layout/build of Contrib. I'm not saying it's a lot, but there is some form of complexity added for sure. I'm just not sure if Contrib needs such complexity? Is it really in the essence of Contrib to store all these Clojure libs? Is that it's purpose? IMO, Contrib is just a way for Rich to allow user contribution to Clojure, without creating havoc on the development of Clojure proper. Often times when someone post a useful function on this group and asks to add it to Core, the response is a unanimous Add it to Contrib and see where it goes from there. This allows Clojure to grow without Rich reading every single contribution because he can rely on community around Contrib to make sound decisions. I believe, if you allow 3rd party libs to penetrate Contrib, then you must allow the same libs to penetrate Clojure itself. To flip it the other way, I think the only deps Contrib should be allowed are the deps used by Core. I think Contirb should remain a breeding ground for Core (if that is indeed its current purpose), and should remain as dead simple and dependency free as possible! I think Clojure libs which require 3rd party deps should be left to their own devices for now. The unification of those can be solved by some build/dependency tool. Maybe there should be a 3rd project called clojure-extensions? This could rely on core, clojure-contrib and any number of 3rd party deps. I do admit, though, that might confuse beginners more than a modularized Contrib. Sorry if I missed the point of this thread, but I thought the question should be asked. What is the purpose of Contrib? P.S. I don't want to get off-track, but I also don't understand why ClojureCLR or clojurescript are included in Contrib. I also don't understand why test files are not under their own top level dir? I think that is a good convention and allows for easier tooling. OK, I'll shut up now. On Apr 15, 4:01 am, dysinger dysin...@gmail.com wrote: +1 I said the same thing on IRC On Apr 14, 11:27 am, Mark Reid mark.r...@gmail.com wrote: Hi, I'm not sure if this is relevant to this discussion but, as a newcomer, I was puzzled by the organisation of the clojure-contrib source. Why, for example, are ClojureCLR and clojurescript at the top of the trunk? Shouldn't these be in separate projects? Regards, Mark. --http://mark.reid.name/ On Apr 14, 10:19 pm, Rich Hickey richhic...@gmail.com wrote: I've been thinking recently about contribs with dependencies. I think it's very important to have layers - e.g. core depends only on JDK 1.5, contrib only on core. Lately there have been some ideas centering around Joda Time, [Parallel]Colt, AWS, JFreeChart, Fork/Join etc. I'd like to start a discussion about how best to support the contributions of libraries that depend on things not in the JDK. Obviously, without care and rules it could get crazy quickly, and I want to avoid the kitchen-sink effect. It is very important that things remain [truly, not just apparently] simple. Looking for suggestions, Rich --~--~-~--~~~---~--~~ 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 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: Contribs with dependencies
My .02 cents... I always viewed Contrib as an incubator of sorts for Core. That it was simply a testing ground for functionality that *MIGHT* make it into Core if enough people find it useful, or Rich hands down his good graces. Requiring a few external libs here and there, and breaking Contrib up into modules may sound simple to some, but I think your quickly forgetting the additional cognitive load of such a decision. If we go the simple route and just require the user to download the libs, then it starts out all well and good, but will quickly turn into dependency hell. Anyone whose been using Linux long enough, or still uses a distro like Slackware knows exactly what I'm talking about. IMO, this is just *NOT* and option. If we create some build or module system around Contrib, we alleviate the dependency problem, but add complexity to the layout/build of Contrib. I'm not saying it's a lot, but there is some form of complexity added for sure. I'm just not sure if Contrib needs such complexity? Is it really in the essence of Contrib to store all these Clojure libs? Is that it's purpose? IMO, Contrib is just a way for Rich to allow user contribution to Clojure, without creating havoc on the development of Clojure proper. Often times when someone post a useful function on this group and asks to add it to Core, the response is a unanimous Add it to Contrib and see where it goes from there. This allows Clojure to grow without Rich reading every single contribution because he can rely on community around Contrib to make sound decisions. I believe, if you allow 3rd party libs to penetrate Contrib, then you must allow the same libs to penetrate Clojure itself. To flip it the other way, I think the only deps Contrib should be allowed are the deps used by Core. I think Contirb should remain a breeding ground for Core (if that is indeed its current purpose), and should remain as dead simple and dependency free as possible! I think Clojure libs which require 3rd party deps should be left to their own devices for now. The unification of those can be solved by some build/dependency tool. Maybe there should be a 3rd project called clojure-extensions? This could rely on core, clojure-contrib and any number of 3rd party deps. I do admit, though, that might confuse beginners more than a modularized Contrib. Sorry if I missed the point of this thread, but I thought the question should be asked. What is the purpose of Contrib? P.S. I don't want to get off-track, but I also don't understand why ClojureCLR or clojurescript are included in Contrib. I also don't understand why test files are not under their own top level dir? I think that is a good convention and allows for easier tooling. OK, I'll shut up now. On Apr 15, 4:01 am, dysinger dysin...@gmail.com wrote: +1 I said the same thing on IRC On Apr 14, 11:27 am, Mark Reid mark.r...@gmail.com wrote: Hi, I'm not sure if this is relevant to this discussion but, as a newcomer, I was puzzled by the organisation of the clojure-contrib source. Why, for example, are ClojureCLR and clojurescript at the top of the trunk? Shouldn't these be in separate projects? Regards, Mark. --http://mark.reid.name/ On Apr 14, 10:19 pm, Rich Hickey richhic...@gmail.com wrote: I've been thinking recently about contribs with dependencies. I think it's very important to have layers - e.g. core depends only on JDK 1.5, contrib only on core. Lately there have been some ideas centering around Joda Time, [Parallel]Colt, AWS, JFreeChart, Fork/Join etc. I'd like to start a discussion about how best to support the contributions of libraries that depend on things not in the JDK. Obviously, without care and rules it could get crazy quickly, and I want to avoid the kitchen-sink effect. It is very important that things remain [truly, not just apparently] simple. Looking for suggestions, Rich --~--~-~--~~~---~--~~ 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 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: speed question
Could Clojure have something similar to CL's 'defconstant'? http://gigamonkeys.com/book/variables.html On Apr 2, 4:09 pm, Bradbev brad.beveri...@gmail.com wrote: It seems to me that the real solution is that the Clojure compiler needs to support global constants. You could probably emulate the behaviour by rebinding global vars inside the let though. (def *foo* 100) (defn bar [] (let [foo *foo*] ...)) Brad On Apr 2, 7:57 am, Paul Stadig p...@stadig.name wrote: I think you are right, Brad. However, I wonder though if there is a better way to define a constant. Neither the macro nor function seems clean. I like David's wrapping-the-whole-thing-in-a-let, but what if you wanted to access the value of width in a different file? Would one have to resort to defining a Java class (at compile time or runtime)? Paul On Thu, Apr 2, 2009 at 10:47 AM, Bradbev brad.beveri...@gmail.com wrote: It would seem that macros in this case should not be required. A normal function that simply returns a constant should get inlined by the JIT. Cheers, Brad --~--~-~--~~~---~--~~ 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 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: Keeping a ref and a DB in sync
Brian, I imagine you are asking this in relation to your blog engine? I came up with solution, that is, if you don't mind writing the persistent data fresh every time. http://paste.lisp.org/display/77987 Basically, I added a watch to the *comment* ref, which set the *db* ref to the new state of the *comment* ref. I wrote a test that hits it with 10 current threads (that each add 10 comments) and then validate that both refs are the same at the end (I borrowed the code from Rich's example on the concurrency page). This is my first real dive into the concurrency aspect of Clojure, and just wanted to play around, but maybe this could give you other ideas. Maybe you could write to a file, and then every so often commit the contents of the file to the db? Like a buffer of commits or something that is persisted to disk. Meh, I'm just throwing up ideas, good luck to ya. On Apr 3, 5:02 am, Brian Carper briancar...@gmail.com wrote: Is there a safe way to keep the data in a Clojure ref and the data in a table in an external (e.g. mysql) database in sync, given concurrent creates/updates/deletes from within Clojure? I can't do a DB update from within a dosync because of retries. If I send-off an agent for the DB update from within a dosync, it won't happen until after the dosync is done, and then if the DB update throws an exception, it'll be too late to rollback the ref and they'll be out of sync. If I do the DB update and ref update separately, there's the potential for race conditions if things happen in between. Is manual locking the only way? --~--~-~--~~~---~--~~ 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 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: VimClojure 2.0.0 released (merged with Gorilla)
Meikel, found a few more things that might need fixing. 1) In the preview window it says Use \p to close this buffer!, but I have m LocalLeader mapped to ,. I'm guessing maybe you hardcoded this by accident? 2) When doing a macroexpand (me or m1), the cursor is moved into the REPL buffer. Is this on purpose? I'd prefer it to stay in it's original buffer and not move. Both of these behaviors were witnessed in MacVim on OS X 10.5.6 if that makes a difference at all. Other than those two things, it's working great for me! Us vimming Clojurians are in your debt. -Ryan --~--~-~--~~~---~--~~ 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 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: version of - short-circuiting on nil
Not that I have any immediate use for this at the moment, but I +1 your proposal. I make use of the ?. operating in Groovy, and it can be helpful. On Mar 10, 4:08 am, Laurent PETIT laurent.pe...@gmail.com wrote: Hello, 2009/3/10 Jason Wolfe jawo...@berkeley.edu (let [person (get-the-person)] (when-not (nil? person) (let [address (.getAddress person)] (when-not (nil? address) (let [street (.getStreet address)] (when-not (nil? street) (do-something-finally-with-street street) ?- sounds potentially useful to me, but let me also point out that you could simplify the above to: (when-let [person (get-the-person)] (when-let [address (.getAddress person)] (when-let [street (.getStreet address)] (do-something-finally-with-street street No, because here, you could also short-circuit on the value false , and not only nil. And it's definitely what I had in a first attempt, and wanted to avoid : having to think about variable names and add several nested levels of lets. Not quite (?- (get-the-person) #(.getAddress %) #(.getStreet %) do-something) but it's halfway there at least. Info on contributing is here: http://clojure.org/contributing The first step is to get your CA signed and in the mail. Yes you're right, I already have sent my CA, and will re-read this page. But I thought that before proposing something (even for clojure-contrib), it would be interesting to see if what I would like to propose sounds interesting to more than one person :-) and if somebody having commit rights on clojure-contrib informally accepts the contrib, before creating an issue with the patch attached ? Thanks, Jason --~--~-~--~~~---~--~~ 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 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: Shouldn't doto be named just with
I think good arguments have been made for doto, but I must say I prefer with slightly more. FWIW, Groovy calls it with. http://javajeff.blogspot.com/2008/11/getting-groovy-with-with.html The great thing about Clojure is that if this really bothered me I could easily take matters into my own hands. (defmacro with [x forms] `(doto ~x ~...@forms)) Clojure rocks! On Mar 6, 7:36 pm, Dimiter \malkia\ Stanev mal...@gmail.com wrote: Thanks for the explanation guys! Having learned other languages, sometimes makes you wanna have the MEMORY UNDO FEATURE! On Mar 6, 3:37 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 07.03.2009 um 00:23 schrieb Laurent PETIT: I'm not sure about this, but I think doto is named after the convention that a lot of side effecting functions/macros/special forms follow : share the do prefix if the name implies that there will be side effects. And indeed, if you use doto with more than one following expression, then this list of expression will generate side effects (mutating the target object, at a minimum). I think doto is actually a good name. In contrast to -, which uses the return value of the expressions doto always calls the given functions or methods using the initial thing. So it does the function calls to the thing. Together with the points Laurent mentioned about the do-prefix indicating side-effects and the slightly different notion of the with-something blocks, I think doto is just good enough a name. Just, my 2¢ and YMMV. Sincerely Meikel smime.p7s 5KViewDownload --~--~-~--~~~---~--~~ 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 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: Unicode, accented characters
On Mar 6, 5:58 pm, max3000 maxime.lar...@gmail.com wrote: I don't really want to use the SVN version because I'm developing an application and can really do without the (normal) instabilities that come with development builds. FYI, you may want to consider using SVN for now because there have been breaking changes[1] since the last release. The general consensus seems to be that breaking changes are allowed until version 1.0 is released. Most of the commits are bug fixes, so IMO it only gets more stable, not less. 1: http://clojure.org/lazier --~--~-~--~~~---~--~~ 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 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: A Clojure documentation browser
On Feb 12, 3:31 pm, Craig Andera craig.and...@gmail.com wrote: Nice work! Thanks. Two things related to 'strcat'. 1) This is already implemented as clojure.core/str (and is more efficient than concat'ing) 2) This function is never called :) Yeah, that code was cut and pasted from some older work I did. It was removed when I started using prxml. I have some idea's related to the presentation, but I don't have time to iterate them right now. Well, pass them on whenever you get a minute. I've recently made some updates that are live on github [1] that may have addressed what you have in mind. Specifically, I've added the ability to collapse/expand an individual namespace or all namespaces. I've uploaded an updated example to the files section of this group [2]. There are two more things I want to do, which probably won't be complete until next week: * See if I can strip the docstring from the displayed source code, since it's redundant. * Move the code into clojure.contrib, probably under the namespace clojure.contrib.gen-html-docs. Later, I may also have a look at making the symbols in the source code hyperlinks to the relevant place in the docs. [1]http://github.com/candera/doc-browse/blob/master/core.clj [2]http://clojure.googlegroups.com/web/clj-libs.html Sorry for the delayed response. I think a problem with the current layout is that once you jump to one of the library sections you have to manually scroll back up to the index. There are a few different ways this could be solved. a) You could just add a top link to each library section banner. b) Only show the currently selected library, and hide the rest. c) Same as above, but also change the library navigation to a tree view. - clojure.contrib.duck-streams -) *default-encoding* -) file -) pwd I did a quick implementation of B, and I think it makes the page feel less cluttered (but I still feel it could be better). However, I did add jQuery as a dependency. I'm not sure how 'light' you were trying to keep this, but jQuery could simplify your JS. Here is a diff: diff --git a/gen_html_docs.clj b/gen_html_docs.clj index eb3616d..2e7e46b 100644 --- a/gen_html_docs.clj +++ b/gen_html_docs.clj @@ -129,12 +129,21 @@ function toggle(targetid, linkid, textWhenOpen, textWhenClosed) } } +$(function() { +$('.lib-link').click(function() { +$('.library').hide(); +var libName = 'library-' + this.text; +$('.library[name=' + libName + ']').show(); +}); +}); + //]] ) (def *style* .library { + display: none; padding: 0.5em 0 0 0 } .all-libs-toggle,.library-contents-toggle @@ -350,8 +359,7 @@ visibility of the library contents. Emits the HTML that documents the namespace identified by the symbol lib. [lib] - [:div {:class library} - [:a {:name (anchor-for-library lib)}] + [:div {:class library :name (anchor-for-library lib)} [:div {:class library-name} [:span {:class library-contents-toggle} [ @@ -388,7 +396,7 @@ lib, a symbol identifying that namespace. [lib] (let [ns (find-ns lib)] (if ns - [:a {:class lib-link :href (str # (anchor-for-library lib))} (str (ns-name ns))]))) + [:a {:class lib-link :href #} (str (ns-name ns))]))) (defn- generate-lib-links Generates the list of hyperlinks to each namespace, given libs, a @@ -434,6 +442,7 @@ libraries. [:head [:title Clojure documentation browser] [:style *style*] +[:script {:type text/javascript :src ./jquery-1.3.1.js} [:raw! ]] [:script {:language JavaScript :type text/javascript} [:raw! *script*]] [:script {:language JavaScript :type text/javascript} Do with my idea as you wish. I just wanted to to throw it out there. I also think the code would be cleaner with the JS and CSS in their own files, but I admit having everything in-lined makes it easy to call. Oh, almost forgot--if you do happen to try out my patch you will notice all the links from 'miglayout.internal' on will not behave correctly. If you look at the DOM with Firebug you'll notice that the 'miglayout' DIV is not being closed and is capturing the others. I didn't have a chance to track down the problem, but you might want to take a look. -Ryan --~--~-~--~~~---~--~~ 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 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: what's the typical usage of fn constantly
Following James's description, I would image constantly's implementation to look something like the following. (defn constantly [value] #(identity value)) If you haven't seen the # macro before, the form below is equivalent. (defn constantly [value] (fn [] (identity value))) Making use of Chris Houser's fine repl-utils library, you can easily view the source at the REPL. user= (clojure.contrib.repl-utils/source constantly) (defn constantly Returns a function that takes any number of arguments and returns x. [x] (fn [ args] x)) Seems I wasn't too far off, the canonical version allows any number of args to be passed, but still just returns the value given at the time of declaration. I think it's safe to view constantly as a function wrapper around 'identity'. user= (clojure.contrib.repl-utils/source identity) (defn identity Returns its argument. [x] x) That is, I would view constantly to be the same as identity except it returns a function which can be passed around, rather than the value itself. Finally, you could just as well do '#(identity the-value)' and get the same result. user= (= (#(identity ab)) ((constantly ab))) true Sorry if I beat this to death; some of it was for my own learning and benefit. On Jan 25, 2:08 pm, wubbie sunj...@gmail.com wrote: thanks James, I'll have a look. -sun On Jan 25, 2:00 pm, James Reeves weavejes...@googlemail.com wrote: On Jan 25, 5:34 pm, wubbie sunj...@gmail.com wrote: What's the typical usage of fn constantly ? When you need a function that constantly returns the same result :) That probably doesn't tell you any more than you know already, so I'll give you a real world use. My rnd-utils library has a function generating random strings that match a regular expression. It does this by converting a regex into a sequence of functions, and then concatenating the results into a string. So a regex like ab[def] would be converted into two functions: [(constantly ab) (rnd-choice def)] This can then be turned into a string using: (apply str (map apply function-sequence)) - James --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
merge, not just for maps?
user= (doc merge) - clojure.core/merge ([ maps]) Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping from the latter (left-to-right) will be the mapping in the result. nil According to merge's doc string it is meant to work on maps. However, this is only part of the truth: user= (merge '(1) 2) (2 1) user= (merge [1] 2) [1 2] user= (merge #{1} 2) #{1 2} Of course, the canonical example: user= (merge {:name ryan} {:age 25}) {:age 25, :name ryan} What's the point? Maybe the doc string should be changed to be more general, or perhaps merge should check that it is indeed working with maps? Personally, this doesn't bother me all that much. However, if people rely on this behavior then it could be harmful if in a future version of Clojure merge only works for maps, or if it's results change for the other types of structures. I feel that a doc string should act as a contract between the function and it's user (think Eiffel). I think the contract for merge could be improved. -Ryan --~--~-~--~~~---~--~~ 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 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 performance matters
On Jan 13, 8:04 am, Mark P pierh...@gmail.com wrote: A macro cannot depend on runtime information. A macro is a function that is called at compile time, its argument is an expression (as written by the programmer, or as returned by another macro), and its result is a modified expression. There is no way a macro could access runtime information. It is a program that works on program code, not on runtime data. Then what do people mean when they say that lisp blurs the distinction between compile-time and run-time? I thought that macros executing at runtime was part of this. But if not, I don't know what they do mean. I thought macros could get executed at runtime as follows. Suppose I have a domain-specific-language implemented in a lisp, using macros. Suppose at runtime some of this domain-specific-code gets generated somehow (code is data at this point). An eval is executed on this domain-specific-code, which causes the macros (used to implement the domain-specific-language) to transform the input code at runtime. Is this wrong? I also thought that when a clojure application is bundled up as java bytecode, this executable actually includes the clojure compiler. Why would this be included if compilation (including macros) is never performed at runtime? Is there something fundamental I am not understanding? Thanks, Mark P. I realize this thread has long since changed gears, but you may find your answer in Chapter 8 of Practical Common Lisp (http:// www.gigamonkeys.com/book/). Look for the section titled 'Macro Expansion vs. Runtime. Basically, it's like Konrad said, macros are executed at 'macro expansion time' which is during the compilation phase. However, Peter Seibel does mention that when interpreted (vs compiled) the line between macro expansion time and runtime becomes kind of fuzzy because they become intertwined. He mentions that it is not explicitly defined when an interpreter must expand macro's. It could expand all the macros up front, or do it lazily as it comes across them, but that doesn't change the fact that they must be expanded first so that the actual runtime code can be produced and executed. Hope this helps. -Ryan --~--~-~--~~~---~--~~ 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 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: finding all vars starting with *
On Jan 8, 5:04 pm, Chouser chou...@gmail.com wrote: On Tue, Jan 6, 2009 at 2:53 PM, rzeze...@gmail.com rzeze...@gmail.com wrote: On Jan 4, 6:05 pm, Brian Doyle brianpdo...@gmail.com wrote: Is there some place where all of these vars are defined? Is there some way programatically I can find them all? Thanks. I'm bored, and as an excuse to write some code I thought I'd try to come up with a solution. You can see it here:http://paste.lisp.org/display/73196 It could be made better with some of the clojure.contrib.ns-utils stuff. I'm a n00b, use at your own risk :) Not bad, though putting all the names into a single string before doing the regex is a bit startling. Here's another crack at it: (doseq [[sym vr] (mapcat ns-publics (all-ns)) :when (re-find #^\* (str sym))] (print-doc vr)) This highlights, though, how many are missing doc strings. Thus:http://code.google.com/p/clojure/issues/detail?id=9 --Chouser The use of a list comprehension and mapcat is much more succinct then my mess :) . I, also, didn't like my big-string/regex; it is indeed ugly. Thanks for the comments, Chris. They are always helpful. -Ryan --~--~-~--~~~---~--~~ 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 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: metadata question
On Jan 7, 10:37 am, Rich Hickey richhic...@gmail.com wrote: On Jan 7, 1:01 am, rzeze...@gmail.com rzeze...@gmail.com wrote: Looking at how the #^ macro is used in core.clj confuses me even more. For example: user= (def #^{:arglist '([name]) :doc Say hello.} hello (fn hello [name] (println (str Hello, name #'user/hello user= (hello ryan) Hello, ryan nil I mean I kind of follow it, but not totally. Is this macro explained somewhere? This might help: http://groups.google.com/group/clojure/msg/919455504c57659e Rich Perfect! Thanks Rich. I actually read over this thread before but completely forgot about it (this group has really picked up steam over the last couple of months). Next time I'll try searching the group more, rather than adding more noise. However, I will reiterate the last threads conclusion. #^ is not a macro for with-meta. That is what I think tripped me up. I may still not understand the full power of #^, but as long as I remember it's not sugar for with-meta than I should at least avoid shooting myself in the foot. -Ryan --~--~-~--~~~---~--~~ 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 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: (alength nil) = java.lang.IllegalArgumentException: More than one matching method found
On Jan 6, 9:54 am, Chouser chou...@gmail.com wrote: On Mon, Jan 5, 2009 at 11:29 PM, rzeze...@gmail.com rzeze...@gmail.com wrote: I was just messing around with array's and produced the following exception. I don't actually need this to work for any reason, but I was rather surprised by the behavior. Is this a bug or expected behavior? Please note I'm using revision 1195. user= (alength nil) java.lang.IllegalArgumentException: More than one matching method found: alength (NO_SOURCE_FILE:146) The docs say Works on arrays of all types and last I checked, nil is not an array of any type. What would you expect it to do? --Chouser Thanks for the reply Chris. I'm not sure what I would expect it to do. I just found the actual exception returned to be odd. For example, compare it to the following: user= (alength ryan) java.lang.IllegalArgumentException: Argument is not an array (NO_SOURCE_FILE:0) That exception makes sense, because I called alength on something that is not a primitive Java array. I would expect the same from calling '(alength nil)' (or maybe even just return nil). This doesn't really bother me, but I just thought I'd be a good steward and mention something on the list. -Ryan --~--~-~--~~~---~--~~ 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 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: finding all vars starting with *
On Jan 4, 6:05 pm, Brian Doyle brianpdo...@gmail.com wrote: Today I found out about the var *file*. I looked it up *file* on clojure.com/api and couldn't find anything. Is there some place where all of these vars are defined? Is there some way programatically I can find them all? Thanks. I'm bored, and as an excuse to write some code I thought I'd try to come up with a solution. You can see it here: http://paste.lisp.org/display/73196 It could be made better with some of the clojure.contrib.ns-utils stuff. I'm a n00b, use at your own risk :) -Ryan --~--~-~--~~~---~--~~ 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 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: metadata question
On Jan 6, 11:35 pm, wubbie sunj...@gmail.com wrote: Hi, Here is the question on differences between with-meta and #^ Specifically 1) and 2) are different in that 1) has meta info carried over to jumping-wubbie, while 2) has not. What's the rationale behind this? user= (def wubbie {:name Wubbie :email wub...@gmail.com}) #'user/wubbie user= wubbie {:name Wubbie, :email wub...@gmail.com} user= ^wubbie nil user= (def jumping-wubbie (with-meta wubbie {:jumping true})) ;; 1) meta info set #'user/jumping-wubbie user= ^jumping-wubbie {:jumping true} user= (def jumping-wubbie2 #^{:jumping true} wubbie) ;; 2) meta inof not carried over #'user/jumping-wubbie2 user= ^jumping-wubbie2 nil Thanks Sun Stu H. mentions this in his book. The briefest way to explain it is with the following code: user= (= #^{:jumping true} {:name Wubbie, :email wub...@mgail.com} #^{:jumping true} wubbie) false In the case of #^{metadata} symbol you are adding the metadata to the symbol, but then the symbol gets evaluated and it's *value* is returned, not the metadata. Maybe this makes it more clear? user= (meta #^{:jumping true} wubbie) nil I'm very much a Clojure n00b, but I would also expect the behavior you were expecting. I wonder if this implementation of #^ was intended, or if this was just an oversight? I think there is something lacking in my fundamental knowledge of Clojure, and that's why this has yet to make complete sense to me. --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
(alength nil) = java.lang.IllegalArgumentException: More than one matching method found
I was just messing around with array's and produced the following exception. I don't actually need this to work for any reason, but I was rather surprised by the behavior. Is this a bug or expected behavior? Please note I'm using revision 1195. user= (alength nil) java.lang.IllegalArgumentException: More than one matching method found: alength (NO_SOURCE_FILE:146) user= (.printStackTrace *e) java.lang.IllegalArgumentException: More than one matching method found: alength (NO_SOURCE_FILE:146) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4139) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.analyze(Compiler.java:3934) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4127) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.analyze(Compiler.java:3934) at clojure.lang.Compiler$BodyExpr$Parser.parse(Compiler.java:3635) at clojure.lang.Compiler$FnMethod.parse(Compiler.java:3474) at clojure.lang.Compiler$FnMethod.access$1100(Compiler.java:3351) at clojure.lang.Compiler$FnExpr.parse(Compiler.java:2937) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4130) at clojure.lang.Compiler.analyze(Compiler.java:3961) at clojure.lang.Compiler.eval(Compiler.java:4166) at clojure.core$eval__3756.invoke(core.clj:1566) at clojure.main$repl__5495$fn__5513.invoke(main.clj:148) at clojure.main$repl__5495.doInvoke(main.clj:145) at clojure.lang.RestFn.invoke(RestFn.java:426) at clojure.main$repl_opt__5537.invoke(main.clj:208) at clojure.main$legacy_repl__5562.invoke(main.clj:249) at clojure.lang.Var.invoke(Var.java:336) at clojure.main.legacy_repl(main.java:29) at clojure.lang.Repl.main(Repl.java:20) Caused by: java.lang.IllegalArgumentException: More than one matching method found: alength at clojure.lang.Compiler.getMatchingParams(Compiler.java:2057) at clojure.lang.Compiler$StaticMethodExpr.init(Compiler.java:1264) at clojure.lang.Compiler$HostExpr$Parser.parse(Compiler.java:760) at clojure.lang.Compiler.analyzeSeq(Compiler.java:4132) ... 21 more nil user= -Ryan --~--~-~--~~~---~--~~ 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 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: Using java.ext.dirs to manage the Classpath for Clojure REPLs
I think this should be fine for 99% of situations, but I think it's also fair to say this is an unorthodox use of java.ext.dirs. I've never really had a firm grip on the idiomatic use of Java's extension mechanism, but I do know that they claim it is for well-established extension/optional packages. One example might be the bouncycastle crypto provider. The one thing I think you do have to be careful about is that if you put something in the extensions path, it will be loaded by the extensions classloader, and you will force everything running on that JVM process to use that particular version (you can get around this, but it's not always obvious). For most applications this shouldn't matter, but for an application that hosts other applications (eg. an application server) this can be problematic. I know from experience after 3 years of dealing with IBM WebSphere. You will probably never run into any problems, but I couldn't help but comment. Another solution you might want to look at is Apache's Common Launcher. It's not the most elegant solution in the world, but it makes it easy to add an entire directory of JARs to the classpath, and it makes it easy to have a cross-platform execution script. On Jan 4, 12:59 pm, Stephen C. Gilardi squee...@mac.com wrote: The java.ext.dirs System property provides a very convenient way to set up and maintain a Classpath for Clojure REPLs. The property can be set from the command line used to launch Clojure (typically within a launcher script). Its value is a list of directories whose *contents* will be the Classpath roots for Clojure. In my case, I set the value of java.ext.dirs to a list of just one directory. That directory contains (relative) symbolic links to all the Jar files and directories I want Clojure to use as its Classpath. As a concrete example, here's what I have in that directory: clojure-contrib.classes - ../../clojure-contrib/classes clojure-contrib.src - ../../clojure-contrib/src clojure.jar - ../../clojure/clojure.jar derby.jar - ../javadb/lib/derby.jar etc - ../../../clj/etc itext-2.0.6.jar - ../jfreechart/lib/itext-2.0.6.jar jcommon-1.0.12.jar - ../jfreechart/lib/jcommon-1.0.12.jar jfreechart-1.0.9.jar - ../jfreechart/lib/jfreechart-1.0.9.jar jsr166y.jar - ../jsr166y/jsr166y.jar local - ../../../clj/local miglayout-3.6-sources.jar - ../miglayout/miglayout-3.6-sources.jar miglayout-3.6-swing.jar - ../miglayout/miglayout-3.6-swing.jar I've enclosed the bash script I'm currently using the launch Clojure. The one required environment variable is CLOJURE_DIRS which I set to the directory containing the links above. I like how simple the script is and how easy it is to manage which jars and directories are available to Clojure REPLs using this method. --Steve (note: using this with clojure.contrib.repl-ln requires revision 337 (of today) or later) #!/bin/bash # clj: Launches a Clojure REPL with command line arguments # # Environment variables: # # Required: # # CLOJURE_DIRS A list of paths to directories containing (either directly # or via symbolic links) the jar files and directories that # Clojure will use as its Classpath. The paths are separated # by File.pathSeparatorChar (: on UNIX). # # Optional: # # CLOJURE_MAIN The Java class to launch # default: clojure.main # example: clojure.contrib.repl_ln # # CLOJURE_OPTS Java options for this REPL's JVM instance # default: # example:-Xms32M -Xmx128M -server # # CLOJURE_INIT Path to an init file to run, an @ prefix specifies a # classpath-relative path. # default: # example:@init.clj set -o errexit set -o nounset #set -o xtrace JAVA=java OPTS=${CLOJURE_OPTS:-} DIRS=-Djava.ext.dirs=${CLOJURE_DIRS} MAIN=${CLOJURE_MAIN:-clojure.main} INIT=${CLOJURE_INIT:+--init ${CLOJURE_INIT}} REPL=--repl exec $JAVA $OPTS $DIRS $MAIN $INIT $REPL $@ smime.p7s 3KViewDownload --~--~-~--~~~---~--~~ 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 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 -~--~~~~--~~--~--~---
code golf
Neat challenge on stackoverflow: http://stackoverflow.com/questions/372668/code-golf-how-do-i-write-the-shortest-character-mapping-program I added an implementation in Clojure. One that I'm sure could be greatly improved on. I don't really care for the extremely obfuscated examples. Sure, it's neat how far Perl can take things, but it's gibberish to me. I tried to follow a middle ground between terse and readable and constrained myself to Clojure only (no contrib). Chouser, where you at? I'm sure you could write something really sweet. -Ryan --~--~-~--~~~---~--~~ 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 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: code golf
On Dec 17, 8:09 pm, Chouser chou...@gmail.com wrote: I don't think I agree with the premise of the question, that golf answers help anyone learn about other languages. But I can't deny that golfing is fun! (defn enc[s e](apply str(map(into{}(for[[o _ n](partition 3 4 e)][o n]))s))) I can't figure out how to edit your stackoverflow answer, but feel free to put my answer in there if you want. It may also be worth noting that to use the command line arguments, you'd just need to add: (apply enc *command-line-args*) --Chouser As always you are very helpful, thanks Chouser! There is a small problem with your solution, however. If the character is not in the encoding your solution will just drop it from the string. But you put me on the right track and here is what I came up with. I could have also built a default map with each character mapping to itself, and then doing an overriding union with the encoding map, but I think this way is more clear (albeit a little obfuscated in my opinion). (defn enc [s e] (apply str (map #(or ((into{} (for [[o _ n] (partition 3 4 e)] [o n])) %) %) s))) --~--~-~--~~~---~--~~ 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 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: In core structure editor, anyone?
On Dec 10, 3:59 pm, falcon [EMAIL PROTECTED] wrote: Could you describe in-core editing a bit more? Sounds interesting. +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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Running out of memory when using filter?
On Dec 7, 1:52 am, Chouser [EMAIL PROTECTED] wrote: On Sun, Dec 7, 2008 at 1:16 AM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I'm also running into, what I believe to be, the same problem. Every time I run the following code I get java.lang.OutOfMemoryError: Java heap space. (use 'clojure.contrib.duck-streams) (count (line-seq (reader big.csv))) If I change count to dorun then it will return without problem. I think I can reproduce this one like so: user= (count (take 15000 (iterate #(str % more) some))) java.lang.OutOfMemoryError: Java heap space (NO_SOURCE_FILE:0) As with yours, I can replace 'count' with 'dorun' and it works fine. I can also use 'last': user= (.length (last (take 15000 (iterate #(str % more) some) 6 I think the problem in this case is 'count', which for all IPersistentCollections (including lazy sequences) calls the 'count' method of the instance. ASeq's count method is a tight for() loop, but since it's an instance method it must retain a 'this' reference to the head of the seq. Fixing this is hard becasue RT.count() is holding onto the head as well. I've attached a patch that fixes the problem, but it's pretty ugly, perhaps only useful to demonstrate that this is the problem. --Chouser count-lazy.patch 1KViewDownload I started a new thread since these problems may be independent of each other. I don't want to get this one off track. http://groups.google.com/group/clojure/browse_thread/thread/41bc83dbe374 --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---