Re: Detecting Number of Available CPU Threads
On Feb 9, 2:37 am, Wardrop t...@tomwardrop.com wrote: That seems like what I'm after, thanks. I assume this would be pretty reliable across all platforms running the JVM. In .NET, on the other hand, this value is stored in System.Environment.ProcessorCount. Perhaps it would be worthwhile to make oft-requested information like this available via a standard API so ClojureCLR and any future ports can maintain consistency? -- You 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: Detecting Number of Available CPU Threads
Hi, On Feb 9, 9:29 pm, Chouser chou...@gmail.com wrote: It may be worth noting that using 'send' to dispatch actions to an agent already takes into account the number of CPUs available. This essentially means it's safe to queue up sends on as many agents as you want -- hundreds, even thousands of agents -- regardless of how many CPUs are on your current host. I think hiding this information is a good thing. It allows to implement strategies like grand central dispatch. Just because there are x CPUs on a system, does not mean that they are to our disposal. (No. We are *not* the only running process in the world.) Sincerely Meikel -- You 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
Importing a class with an ambiguous name
Hi, I'm exploring the jexcelapi library (http:// jexcelapi.sourceforge.net), and one of the classes there is jxl.write.Number. So, when I do: = (import 'jxl.write.Number) I get: Number already refers to: class java.lang.Number in namespace: user [Thrown class java.lang.IllegalStateException] I tried excluding the Number symbol from the current namespace but that doesn't work (or I'm doing it wrong). So, how do I import classes with names that already exist in my namespace? p.s. As far as writing Excel spreadsheets is concerned, I'm aware of the Apache POI project, this one is the next on my list... Thanks, Igor Rumiha -- You 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: Importing a class with an ambiguous name
If I remember correctly it will work just fine if you don't import it and you refer to it like (jxl.write.Number... Please correct me if I'm wrong. Joop Kiefte 2010/2/11 igorrumiha igorrum...@gmail.com Hi, I'm exploring the jexcelapi library (http:// jexcelapi.sourceforge.net), and one of the classes there is jxl.write.Number. So, when I do: = (import 'jxl.write.Number) I get: Number already refers to: class java.lang.Number in namespace: user [Thrown class java.lang.IllegalStateException] I tried excluding the Number symbol from the current namespace but that doesn't work (or I'm doing it wrong). So, how do I import classes with names that already exist in my namespace? p.s. As far as writing Excel spreadsheets is concerned, I'm aware of the Apache POI project, this one is the next on my list... Thanks, Igor Rumiha -- You 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You 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
Clojure and OOP
Hey, Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure and OOP
On 11 February 2010 22:46, HB hubaghd...@gmail.com wrote: Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? You might find this article interesting: http://blog.thinkrelevance.com/2009/8/12/rifle-oriented-programming-with-clojure-2 And related: http://stackoverflow.com/questions/1517855/clojure-allows-encapsulation-and-inheritance-but-can-i-combine-them Regards, Tim. -- You 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: Importing a class with an ambiguous name
On Feb 11, 1:24 pm, Joop Kiefte iko...@gmail.com wrote: If I remember correctly it will work just fine if you don't import it and you refer to it like (jxl.write.Number... Please correct me if I'm wrong. You are correct! Thanks! -- Igor Rumiha -- You 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 and OOP
On Feb 11, 12:46 pm, HB hubaghd...@gmail.com wrote: Hey, Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Thanks. To quote Dr. Alan Kay: OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them. I suspect that Clojure is actually more suited to OOP than Java, assuming you're going by Dr. Kay's definition. :) - 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 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 and OOP
You can work with java objects. But clojure itself is not object oriented, because it's functional, and object orientation requires state manipulation. Other lisps support object orientation, common-lisp for example. cheers, /J On Thu, Feb 11, 2010 at 1:46 PM, HB hubaghd...@gmail.com wrote: Hey, Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To 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.contrib.test-contrib.test-jmx build error
I think you're running into http://bugs.sun.com/view_bug.do?bug_id=6924497 which is unrelated to JMX itself but is a problem of incompatibility between the JDK class library and the JVM, if for example you are running with HotSpot Express. A fix should appear in a JDK 6 update but in the meantime it's probably best to change the test so it doesn't tickle this bug. One way to do that would be to look only at MBeans with an ObjectName matching java.lang:*. Regards, Éamonn McManus, JMX Spec Lead -- You 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 and OOP
Joel Westerberg wrote: You can work with java objects. But clojure itself is not object oriented, because it's functional, and object orientation requires state manipulation. By whose definition? Are you saying there is no such thing as an immutable object? Other lisps support object orientation, common-lisp for example. Clojure is not purely functional. In fact, it has special support for managing mutable state in coherent ways. -- You 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
Multimethods vs. cond?
I'm wondering what the rationale is for using multimethods vs. cond, and where it's best to use either? Multimethods seem to be very seldom used, usually to dispatch on type, but I can see advantages to using data to dynamically define only the methods you need, rather than having all-encompassing cond statements. It also seems like generally cleaner code. Is there a speed benefit to one or the other? -- You 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 and OOP
The problem is about the overloading of the object based expression. A step forward could be to recognize that: * Java is a weak/simplified version of a class based language (simplifications made for several well known reasons: ease of adoption by C/C++ crowd: - algol like syntax-, reduced functionalities for debatable reasons: e.g. no C++ multiple inheritence/templates/pointers-, not fully class based for debatable performance reasons: primitive types, not everything is a class method). It did at least have the good property of popularizing the JVM and the notion of garbage collection, to cite the most evident to me. * Javascript (at least in its ancestral forms, don't know for sure since the later ECMA standardizations) is a prototype based language = true object orientation, methods belong to objects, not to their classes (by belong, I mean one can redefine methods on an object basis) * Smalltalk is a pure class based language. No static methods in smalltalk, thanks to its correct use of the meta-class concept. * Clojure is a pragmatic language, function based, with a clear story for managing the parts of your application which require manipulation of internal (essential) state, or external (I/O resources) state. I don't know if it is at all possible to map the concept of object orientation to one category and not the other ... 2010/2/11 Jeff Schwab j...@schwabcenter.com: Joel Westerberg wrote: You can work with java objects. But clojure itself is not object oriented, because it's functional, and object orientation requires state manipulation. By whose definition? Are you saying there is no such thing as an immutable object? Other lisps support object orientation, common-lisp for example. Clojure is not purely functional. In fact, it has special support for managing mutable state in coherent ways. -- You 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
Clojure NYC Users Group looking for speakers!
We had about 60 people show up for our first meeting and I've had some very positive feedback and a couple of companies have approached me about sponsoring our next meeting. We are looking for speakers to talk about anything Clojure. The group is a mix of people using Clojure commercially to people just interested in learning more about the language. Any topics from basic Clojure tutorials, advanced topics in concurrency from experimental to production level talks I think would be welcomed by the group. Please contact me if you would like to give a talk at our group or have any suggestions for getting speakers, etc. For more information see: http://www.meetup.com/Clojure-NYC/ Thanks! Eric -- You 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: Multimethods vs. cond?
2010/2/11 Bryce fiat.mo...@gmail.com: I'm wondering what the rationale is for using multimethods vs. cond, and where it's best to use either? Multimethods seem to be very seldom used, usually to dispatch on type, but I can see advantages to using data to dynamically define only the methods you need, rather than having all-encompassing cond statements. It also seems like generally cleaner code. Is there a speed benefit to one or the other? There is clearly a speed benefit of just using cond, and sometimes it can be the reason for the choice. multimethods help you implement the Open / Close principle : they are open to users providing more specific implementations for more specific dispatch values. And for this it is not necessary for the user of the multimethod to change existing implementations for certain dispatch values (the close part). There's certainly much to say about the differences, but here's my contribution. HTH, -- Laurent -- You 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 and OOP
can we creat threads in clojure? On Feb 11, 8:11 pm, Laurent PETIT laurent.pe...@gmail.com wrote: The problem is about the overloading of the object based expression. A step forward could be to recognize that: * Java is a weak/simplified version of a class based language (simplifications made for several well known reasons: ease of adoption by C/C++ crowd: - algol like syntax-, reduced functionalities for debatable reasons: e.g. no C++ multiple inheritence/templates/pointers-, not fully class based for debatable performance reasons: primitive types, not everything is a class method). It did at least have the good property of popularizing the JVM and the notion of garbage collection, to cite the most evident to me. * Javascript (at least in its ancestral forms, don't know for sure since the later ECMA standardizations) is a prototype based language = true object orientation, methods belong to objects, not to their classes (by belong, I mean one can redefine methods on an object basis) * Smalltalk is a pure class based language. No static methods in smalltalk, thanks to its correct use of the meta-class concept. * Clojure is a pragmatic language, function based, with a clear story for managing the parts of your application which require manipulation of internal (essential) state, or external (I/O resources) state. I don't know if it is at all possible to map the concept of object orientation to one category and not the other ... 2010/2/11 Jeff Schwab j...@schwabcenter.com: Joel Westerberg wrote: You can work with java objects. But clojure itself is not object oriented, because it's functional, and object orientation requires state manipulation. By whose definition? Are you saying there is no such thing as an immutable object? Other lisps support object orientation, common-lisp for example. Clojure is not purely functional. In fact, it has special support for managing mutable state in coherent ways. -- You 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- Hide quoted text - - Show quoted text - -- You 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 reporting for macro expansion
I'm concerned specifically about exceptions that occur during macro expansion. As often as not, these exceptions are the result of calling the macro with incorrect arguments rather than any problem in the macro itself, but the stack trace doesn't contain enough information to locate the offending macro call. For instance, the stack trace I posted reports macro-fail.clj line 0 as the ultimate source of the problem, even though the macro is called on line 3. I've done some more tests using the 1.0 release as well as the latest head from git, and in both versions, the stack trace contains the name of the file where the macro is called, but the line number is always 0. Since the file name is correct, I think my comments about hacking the reader were off-base, but there is definitely a problem with reporting the correct line number. On Mon, Feb 8, 2010 at 2:08 PM, Michał Marczyk michal.marc...@gmail.comwrote: On 8 February 2010 20:11, John R. Williams shponglesp...@gmail.com wrote: ;; macro-fail.clj (defmacro broken [] (/ 0 0)) (broken) [ ... ] As you can see, line 3, where the macro is used, appears nowhere in the stack trace. That's because execution never reaches this point, because the (/ 0 0) bit gets executed at macro expansion time. You'd have to syntax-quote it to fail at runtime: (defmacro broken [] `(/ 0 0)) (A regular quote would probably also do.) Also, note the user$broken ... line in your stack trace -- it does contain a useful indication of the source of the problem. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To 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 reporting for macro expansion
In the example, you can find a reference to the actual macro (line and name) in the second part (Caused by:). By the nature of macro's I think this might be not the most human way to get the line number, but surely the way the JVM sees it. 2010/2/11 John Williams shponglesp...@gmail.com I'm concerned specifically about exceptions that occur during macro expansion. As often as not, these exceptions are the result of calling the macro with incorrect arguments rather than any problem in the macro itself, but the stack trace doesn't contain enough information to locate the offending macro call. For instance, the stack trace I posted reports macro-fail.clj line 0 as the ultimate source of the problem, even though the macro is called on line 3. I've done some more tests using the 1.0 release as well as the latest head from git, and in both versions, the stack trace contains the name of the file where the macro is called, but the line number is always 0. Since the file name is correct, I think my comments about hacking the reader were off-base, but there is definitely a problem with reporting the correct line number. On Mon, Feb 8, 2010 at 2:08 PM, Michał Marczyk michal.marc...@gmail.comwrote: On 8 February 2010 20:11, John R. Williams shponglesp...@gmail.com wrote: ;; macro-fail.clj (defmacro broken [] (/ 0 0)) (broken) [ ... ] As you can see, line 3, where the macro is used, appears nowhere in the stack trace. That's because execution never reaches this point, because the (/ 0 0) bit gets executed at macro expansion time. You'd have to syntax-quote it to fail at runtime: (defmacro broken [] `(/ 0 0)) (A regular quote would probably also do.) Also, note the user$broken ... line in your stack trace -- it does contain a useful indication of the source of the problem. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To 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.comclojure%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- Communication is essential. So we need decent tools when communication is lacking, when language capability is hard to acquire... - http://esperanto.net - http://esperanto-jongeren.nl Linux-user #496644 (http://counter.li.org) - first touch of linux in 2004 -- You 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: Multimethods vs. cond?
Yeah, in practice it seems like multimethods are pretty much just used as a way to let users of a library extend the API to support additional types. If you had a cond expression dispatching on the type of an argument, for example, then the user would have to modify the source code of your library to add support for their custom type. With multi-methods the user can implement a method defined in the library that dispatches on their own type, and the code can stay within their own project. I have a feeling multimethods could be useful for of plenty other things, but so far that's all I've seen or done with them. -Jeff On Feb 11, 4:27 pm, Laurent PETIT laurent.pe...@gmail.com wrote: 2010/2/11 Bryce fiat.mo...@gmail.com: I'm wondering what the rationale is for using multimethods vs. cond, and where it's best to use either? Multimethods seem to be very seldom used, usually to dispatch on type, but I can see advantages to using data to dynamically define only the methods you need, rather than having all-encompassing cond statements. It also seems like generally cleaner code. Is there a speed benefit to one or the other? There is clearly a speed benefit of just using cond, and sometimes it can be the reason for the choice. multimethods help you implement the Open / Close principle : they are open to users providing more specific implementations for more specific dispatch values. And for this it is not necessary for the user of the multimethod to change existing implementations for certain dispatch values (the close part). There's certainly much to say about the differences, but here's my contribution. HTH, -- Laurent -- You 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 and OOP
On 11 February 2010 13:46, HB hubaghd...@gmail.com wrote: Hey, Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Thanks. Regardless of whether Clojure supports OOP, not supporting it certainly doesn't follow from being a Lisp dialect. Take a look at CLOS (Common Lisp Object System), for instance. Incidentally, CLOS was, AFAIK, originally engineered as a package of macros and functions built on top of CL's core and only later included in the language standard. Similarly for being functional: apart from Clojure, Ocaml and F# offer OOP-like syntactic features in otherwise mostly functional language packages. While for F# this might be considered an interop feature, that's certainly not the case with Ocaml. I'm ill prepared to debate the correct definition of object orientation, so I won't offer one, but at the very least I feel justified in believing that there simply isn't one superior approach to OOP (personally, I'm partial to the approach of not prodding it with less than a 10 foot pole, but... um... never mind). If anything, Clojure's being a Lisp makes it easier to come up with your own approach, code it up and use it. And then the Java approach is obviously directly accessible through the Java interop facilities; perhaps not all of it at this stage, but enough to give one's code quite a Javaish smell if one so desires. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Request for Feedback: Improve VimClojure's documentation
i can echo that last reply. I wanted to use clojure and may return to it ... awesome idea. But haven't had ANY luck with dev environments ... VC, included. gone down many blind alleys. It was almost a year ago that I tried, though. perhaps I should try again. On Thu, Feb 11, 2010 at 12:44 PM, Drew Vogel drewpvo...@gmail.com wrote: The result is horrible error messages like the one in the attached screenshot. I don't have a solution to contribute because I've never consistently solved these problems. Good luck with this effort. I'd like to see VC become more accessible. -- You 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
small code review..
Hi, I'm doing my first steps in Clojure and I would like to get some feedback on my implementation of the Bowling Game Kata. The code is here http://softnoise.wordpress.com/2010/02/07/the-bowling-kata-in-clojure. I can post the code here if that's preferred. I'm mostly interested if there is anything in my code one would/should never do that way. Thanks Martin -- You 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 and OOP
Instead of getting caught up in whether or not it supports OOP, and how to define OOP, I recommend watching http://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey. On Feb 11, 6:46 am, HB hubaghd...@gmail.com wrote: Hey, Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Thanks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure and OOP
Hi, On Feb 11, 1:46 pm, HB hubaghd...@gmail.com wrote: Since Clojure is a LISP dialect, does this mean that it doesn't support OOP? Careful not to come to the conclusion that if something's a Lisp, it's not OOP. For instance, Common Lisp has a powerful OOP system which includes multiple-inheritance, metaobject protocol, and so forth. http://en.wikipedia.org/wiki/Common_Lisp_Object_System The world is a bit upside-down. I suspect people would look at me strangely if I claimed that C++ wasn't seriously OOPish. However, Alan Kay claimed: Actually I made up the term object-oriented, and I can tell you I did not have C++ in mind. -- http://video.google.com/videoplay?docid=-2950949730059754521 ... and later in that video strongly regrets coining the term, as it gives the wrong impression. OOP is a term which can mean many (even conflicing?) things, as Jonathan Rees discussed: http://www.paulgraham.com/reesoo.html As for Clojure, Rich Hickey claims it's not OOP. I guess he means this: Instead of modelling me as an object whose internal state changes as I change (from moment to moment), you instead model me as a reference which points to a different immutable value as I change. That is, I'm a different person from the one a few seconds ago; just that my identity points to the most recent version of me. (As a software optimization, those immutable versions may share significant structure.) This means that if you took a snapshot of me (an immutable value), that snapshot won't change. You'll just have an old version of me. But in a traditional OOP language, if you had a pointer to my object, that object could be updated willy-nilly by other threads; you'd need to make a threadsafe deep copy of me or something, to have an immutable snapshot. I hope I grok the Clojure Way well enough that my explanation is right. http://clojure.org/state Incidentally, you could create your own OOP system on top of Clojure, if you wish. All the best, Tayssir -- You 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 and OOP
I suspect that Clojure is actually more suited to OOP than Java, assuming you're going by Dr. Kay's definition. :) Another Kay quote: I invented Object-Oriented Programming, and C++ is not what I had in mind. -- You 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: small code review..
Martin, It's very simple, I like it. There two things that stand out to me, both having to do with readabiliby. Instead of using (def score) you should use (declare score). declare exists for the purpose of making forward declarations. That one is black and white. You have to do it. The other I am not so sure about. You create a function named sum which calls (reduce + rolls). I think that an experienced Clojure programmer would rather just see (reduce + (take 2 rolls)) rather than (sum (take 2 rolls)). There are two reasons you may want to create the sum function. One bad and one not so bad. The first is that you think reduce + is confusing and so you are creating a name that makes more sense to you. The second is that you are going to be using it a lot and you want to save 5 keystrokes. I have issue with the first reason. When an experienced Clojure dev sees (reduce + (take 2 rolls)) there is only one foreign idea to think about, namely rolls. When they see (sum (take 2 rolls)) the complexity has increased because they now they have two foreign ideas to think about. Another way to think about it is that when I see (reduce + (take 2 rolls)) I know exactly what it does. When I see (sum (take 2 rolls)), I don't know what it does. sum could be some crazy, messed up side effecting function that could cause all kinds of problems. In your code it is easy to check that sum is correct but what if it was implemented in another file? I only point this out because I find myself doing this all the time. Brenton On Feb 11, 9:19 am, Martin Hauner martin.hau...@gmx.net wrote: Hi, I'm doing my first steps in Clojure and I would like to get some feedback on my implementation of the Bowling Game Kata. The code is herehttp://softnoise.wordpress.com/2010/02/07/the-bowling-kata-in-clojure. I can post the code here if that's preferred. I'm mostly interested if there is anything in my code one would/should never do that way. Thanks Martin -- You 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
Simple clojure and contrib install, with SLIME ... ?
I struggle fairly often with keeping clojure/contrib/slime up to date on my machine - it seems that every time I update it, something fundamental has broken (like build.xml going away in contrib). There are a few things that seem to try to make this easier (like clojure- mode's install-clojure, or ClojureX) but they also seem unable to keep up with the speed of some of the changes that are happening (or, quite possibly, I'm using them incorrectly or ineffectively). What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? Thanks for any help! -- You 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: Simple clojure and contrib install, with SLIME ... ?
What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Maven, but I can't say I like it -- IMO there was nothing wrong with ant for contrib, which has no dependencies! Swank-clojure I have checked out from GitHub, and I rebuild as appropriate when switching between 1.1 and 1.2 (which seem to produce incompatible compiled code). -- You 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: Simple clojure and contrib install, with SLIME ... ?
I just have a hard time keeping it working when I update. I understand that being on the bleeding edge is rough, but it's hard for me to think that this isn't especially frustrating for new users, who I suspect will find that most tutorials or guides to setting up clojure with slime (for example) aren't going to work at all. On Feb 11, 11:07 am, Richard Newman holyg...@gmail.com wrote: What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Maven, but I can't say I like it -- IMO there was nothing wrong with ant for contrib, which has no dependencies! Swank-clojure I have checked out from GitHub, and I rebuild as appropriate when switching between 1.1 and 1.2 (which seem to produce incompatible compiled code). -- You 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: Simple clojure and contrib install, with SLIME ... ?
On 11 February 2010 19:59, Paul Mooser taron...@gmail.com wrote: What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? If you don't need to insist on running your own build, you can always get the latest jars for Clojure and contrib from build.clojure.org. On 11 February 2010 20:07, Richard Newman holyg...@gmail.com wrote: I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Maven, but I can't say I like it -- IMO there was nothing wrong with ant for contrib, which has no dependencies! inc! A hundred times inc! (Also, it's an *essential feature* of contrib that it doesn't have any external dependencies -- thus there's no point in using maven for it *at all*.) Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Multimethods vs. cond?
hi, the expression problem (http://en.wikipedia.org/wiki/Expression_Problem) talks about some of the relevant trade-offs. sincerely. -- You 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: Contributing to Clojure.Contrib
On 11 February 2010 00:44, Sean Devlin francoisdev...@gmail.com wrote: Take a look here: http://clojure.org/contributing Um... I strongly suspect that this may be a supremely silly question, but I can't seem to figure out what's supposed to go in some of the fields. Does one specify Clojure as the first project and Clojure Contrib as the second, providing two user names in each of the user name fields (one for GitHub, one for Assembla)? Or does one send in two CAs? I'd really appreciate it if someone could tell me exactly what would the top table of John R. Hacker's CA look like. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Request for Feedback: Improve VimClojure's documentation
Here are some windows friendly options: http://vimeo.com/tag:install_clojure Sean On Feb 11, 1:11 pm, e evier...@gmail.com wrote: i can echo that last reply. I wanted to use clojure and may return to it ... awesome idea. But haven't had ANY luck with dev environments ... VC, included. gone down many blind alleys. It was almost a year ago that I tried, though. perhaps I should try again. On Thu, Feb 11, 2010 at 12:44 PM, Drew Vogel drewpvo...@gmail.com wrote: The result is horrible error messages like the one in the attached screenshot. I don't have a solution to contribute because I've never consistently solved these problems. Good luck with this effort. I'd like to see VC become more accessible. -- You 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
Help me make this more idiomatic clojure
Hi all, long time lurker first time irritant. I have been playing with clojure for a little while, and finding it most excellent; however my lack of lisp thinking keeps leading me to write ugly code. I have the following code in java: -- static final String CONNECTOR_ADDRESS = com.sun.management.jmxremote.localConnectorAddress; VirtualMachine vm = VirtualMachine.attach(id); String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); // no connector address, so we start the JMX agent if (connectorAddress == null) { String agent = vm.getSystemProperties().getProperty(java.home) + File.separator + lib + File.separator + management-agent.jar; vm.loadAgent(agent); // agent is started, get the connector address connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); } - I have translated this into the following clojure form --- (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid)] (let [aquire-connector #(.. vm (getAgentProperties) (getProperty com.sun.management.jmxremote.localConnectorAddress))] (if (aquire-connector) aquire-connector (do (. vm (loadAgent (apply str (interpose java.io.File/separator (list (.. vm (getSystemProperties) (getProperty java.home)) lib management-agent.jar) (aquire-connector ;(. vm detach)) )) --- My question would be is there a better way to express this ? Many thanks -- Greg Bowyer -- You 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
Reading data from a file into a struct
Hi All – I would like to read in a text file and map the results to a struct, and seem to be hung up. The data set would look like: Minneapolis\tMN\t55409 Beverly Hills\tCA\t90210 New York City\tNY\t10023 Etc…. Using duck streams: (defn load-data [f] (into [] (ds/read-lines f))) Yields a long sequence of city, state, and zip. I would like to insert those results into a struct (defstruct location :city :state :zip) I have also tried to use something like : (defn process-file [file-name] (with-open [rdr (BufferedReader. (FileReader. file-name))] (doseq [line (line-seq rdr)] _CANNOT_FIGURE_OUT_WHAT_TO_DO_HERE))) Any help would be tremendously appreciated! Thanks Base -- You 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: Help me make this more idiomatic clojure
You can use get on Properties. Use .foo for method calls. Use literal vec syntax, not list. Use or for conditional branches instead of (if foo foo ...). Untested: (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid) props (.getSystemProperties vm) acquire-connector (fn [] (get (.getAgentProperties vm) com.sun.management.jmxremote.localConnectorAddress))] (or (acquire-connector) (do (.loadAgent vm (apply str (interpose java.io.File/separator [(get props java.home) lib management-agent.jar]))) (acquire-connector -- You 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: Help me make this more idiomatic clojure
You can also you #_ to comment out a line of code #_(.vm detach) so that you don't have to put )) on the next line. Brenton On Feb 11, 10:39 am, Greg Bowyer gbow...@fastmail.co.uk wrote: Hi all, long time lurker first time irritant. I have been playing with clojure for a little while, and finding it most excellent; however my lack of lisp thinking keeps leading me to write ugly code. I have the following code in java: -- static final String CONNECTOR_ADDRESS = com.sun.management.jmxremote.localConnectorAddress; VirtualMachine vm = VirtualMachine.attach(id); String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); // no connector address, so we start the JMX agent if (connectorAddress == null) { String agent = vm.getSystemProperties().getProperty(java.home) + File.separator + lib + File.separator + management-agent.jar; vm.loadAgent(agent); // agent is started, get the connector address connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); } - I have translated this into the following clojure form --- (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid)] (let [aquire-connector #(.. vm (getAgentProperties) (getProperty com.sun.management.jmxremote.localConnectorAddress))] (if (aquire-connector) aquire-connector (do (. vm (loadAgent (apply str (interpose java.io.File/separator (list (.. vm (getSystemProperties) (getProperty java.home)) lib management-agent.jar) (aquire-connector ;(. vm detach)) )) --- My question would be is there a better way to express this ? Many thanks -- Greg Bowyer -- You 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: Help me make this more idiomatic clojure
Sorry, you are not commenting out a line of code but ignoring the next form. On Feb 11, 12:49 pm, Brenton bashw...@gmail.com wrote: You can also you #_ to comment out a line of code #_(.vm detach) so that you don't have to put )) on the next line. Brenton On Feb 11, 10:39 am, Greg Bowyer gbow...@fastmail.co.uk wrote: Hi all, long time lurker first time irritant. I have been playing with clojure for a little while, and finding it most excellent; however my lack of lisp thinking keeps leading me to write ugly code. I have the following code in java: -- static final String CONNECTOR_ADDRESS = com.sun.management.jmxremote.localConnectorAddress; VirtualMachine vm = VirtualMachine.attach(id); String connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); // no connector address, so we start the JMX agent if (connectorAddress == null) { String agent = vm.getSystemProperties().getProperty(java.home) + File.separator + lib + File.separator + management-agent.jar; vm.loadAgent(agent); // agent is started, get the connector address connectorAddress = vm.getAgentProperties().getProperty(CONNECTOR_ADDRESS); } - I have translated this into the following clojure form --- (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid)] (let [aquire-connector #(.. vm (getAgentProperties) (getProperty com.sun.management.jmxremote.localConnectorAddress))] (if (aquire-connector) aquire-connector (do (. vm (loadAgent (apply str (interpose java.io.File/separator (list (.. vm (getSystemProperties) (getProperty java.home)) lib management-agent.jar) (aquire-connector ;(. vm detach)) )) --- My question would be is there a better way to express this ? Many thanks -- Greg Bowyer -- You 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: Help me make this more idiomatic clojure
Most of that java code is just pasting together library function calls. I'm not sure if there's any more elegant ways of doing that. Your clojure code looks fine for the most part I think. It's mostly just a question of style. The only thing that sticks out is the call to (list). That's generally never needed in Clojure. You just use a vector instead. Here's how I would write your code. Nothing much has changed. Just personal style: (defn str-interpose [sep strings] (apply str (interpose sep strings))) (defn acquire-address [vm] (.getProperty (.getAgentProperties vm) com.sun.management.jmxremote.localConnectorAddress)) (defn load-agent [vm] (.loadAgent vm (str-interpose File/separator [(.. vm getSystemProperties (getProperty java.home)) lib management-agent.jar]))) (defn obtain-local-connection [vmid] (let [vm (VirtualMachine/attach vmid) address (or (acquire-address vm) (do (load-agent vm) (acquire-address vm)))] (.detach vm) address)) -- You 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: Simple clojure and contrib install, with SLIME ... ?
On 11 February 2010 21:07, Richard Newman holyg...@gmail.com wrote: What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Maven, but I can't say I like it -- IMO there was nothing wrong with ant for contrib, which has no dependencies! I must say that I *hate* it when I just want to compile something and the bloody build system decides to download a bunch of crap. Especially when it worked fine without all of that before. And then it wants to download clojure-something-SNAPSHOT.jar when I have it compiled locally already! The recent packaging thread did give me some hope that maybe Maven was not such a bad idea, but it's yet another thing to learn because I don't like the defaults of wasting my precious bandwidth and time. Sorry for the rant :) -- Michael Wood esiot...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Clojure and OOP
On 11 February 2010 17:57, John Pall johnabcd.a...@gmail.com wrote: can we creat threads in clojure? Yes. Clojure 1.2.0-master-SNAPSHOT user= (Thread.) #Thread Thread[Thread-0,5,main] But often you would use an agent or pmap etc. instead of creating explicit threads. -- Michael Wood esiot...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Simple clojure and contrib install, with SLIME ... ?
On Thu, Feb 11, 2010 at 10:59 AM, Paul Mooser taron...@gmail.com wrote: I struggle fairly often with keeping clojure/contrib/slime up to date on my machine - it seems that every time I update it, something fundamental has broken (like build.xml going away in contrib). There are a few things that seem to try to make this easier (like clojure- mode's install-clojure, or ClojureX) but they also seem unable to keep up with the speed of some of the changes that are happening (or, quite possibly, I'm using them incorrectly or ineffectively). M-x install-clojure has been deprecated for quite some time now. If you work from the swank-clojure readme you should be able to get a usable setup with no headaches since it doesn't involve compiling code locally anymore. The CI server at build.clojure.org handles compilation issues for you, and only the stable versions of the elisp libraries are present on ELPA since those don't change very much any more. http://github.com/technomancy/swank-clojure If there are problems with the instructions there please bring them up on the mailing list or file a bug. but it's hard for me to think that this isn't especially frustrating for new users, who I suspect will find that most tutorials or guides to setting up clojure with slime (for example) aren't going to work at all. Outdated documentation is an annoyance for any project. I've kept the official docs up to date, but there are so many blog posts out there that point people towards methods that don't work any more; there's not much that can be done about that. Just pay attention to the posting date when you are looking for things like this; if you find a post that's over six months old you might need to think twice. -Phil -- You 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: Reading data from a file into a struct
How about (for [line (ds/read-lines file)] (apply struct location (rest (re-match #([\w ]+)\t([\w ]+)\t([\w ]+)\t line ? Or (for [line (ds/read-lines file)] (let [[_ city state zip] (re-match #... line)] ; possibly with regex from above (struct location city state zip))) Use your regex of choice if there's something the matter with the one above. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: refs, agents and add-watch
As Michael said, your original code works fine for me (running 1.2.0 master). user= (do (send artisan manufacture) (println @material @products @products-store)) 4 3 2 nil user= (do (send artisan manufacture) (println @material @products @products-store)) 3 0 6 nil user= (do (send artisan manufacture) (println @material @products @products-store)) 2 1 6 nil user= (do (send artisan manufacture) (println @material @products @products-store)) 1 2 6 nil Without seeing the actual exception, it's hard to diagnose what you're running into. What version of clojure are you running? Out of curiosity why did you structure your code that way, as opposed to something like: (defn manufacture [state] (dosync (alter material ask-materials) (alter products send-products)) (str idle)) I'm not sure what the full story is behind the intent of watchers, but it smells funny to me to have them modify the ref whose modification triggered them. As for dumping the state-change of refs, add-watch seems the right path, though you don't need to repeat yourself: (defmacro dump [ refs] `(do ~@(for [r refs] `(add-watch ~r :dump (fn [k# r# o# n#] (println '~r o# = n#)) (dump material products products-store) One issue with the above is that the printlns occur in the agent threads, so the output to the repl can look weird. -- You 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: Reading data from a file into a struct
Fantastic! A million thank yous Michal! On Feb 11, 3:40 pm, Michał Marczyk michal.marc...@gmail.com wrote: How about (for [line (ds/read-lines file)] (apply struct location (rest (re-match #([\w ]+)\t([\w ]+)\t([\w ]+)\t line ? Or (for [line (ds/read-lines file)] (let [[_ city state zip] (re-match #... line)] ; possibly with regex from above (struct location city state zip))) Use your regex of choice if there's something the matter with the one above. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
More contrib renaming: c.c.java is gone
As part of our clojure-contrib clean-up effort: * c.c.java is gone * as-str moved to c.c.string * as-file and as-url moved to c.c.io * properties stuff moved to c.c.properties * wall-hack stuff move to c.c.reflect These changes have been committed to the master branch on Github. -SS -- You 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: Reading data from a file into a struct
On 11 February 2010 22:48, Base basselh...@gmail.com wrote: Fantastic! A million thank yous Michal! Not at all. :-) Sincerely, Michał -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Simple clojure and contrib install, with SLIME ... ?
Thanks a lot for your reply, Phil - I had no idea it was deprecated. I'll make an effort to do what you've suggested! On Feb 11, 1:29 pm, Phil Hagelberg p...@hagelb.org wrote: On Thu, Feb 11, 2010 at 10:59 AM, Paul Mooser taron...@gmail.com wrote: I struggle fairly often with keeping clojure/contrib/slime up to date on my machine - it seems that every time I update it, something fundamental has broken (like build.xml going away in contrib). There are a few things that seem to try to make this easier (like clojure- mode's install-clojure, or ClojureX) but they also seem unable to keep up with the speed of some of the changes that are happening (or, quite possibly, I'm using them incorrectly or ineffectively). M-x install-clojure has been deprecated for quite some time now. If you work from the swank-clojure readme you should be able to get a usable setup with no headaches since it doesn't involve compiling code locally anymore. The CI server at build.clojure.org handles compilation issues for you, and only the stable versions of the elisp libraries are present on ELPA since those don't change very much any more. http://github.com/technomancy/swank-clojure If there are problems with the instructions there please bring them up on the mailing list or file a bug. but it's hard for me to think that this isn't especially frustrating for new users, who I suspect will find that most tutorials or guides to setting up clojure with slime (for example) aren't going to work at all. Outdated documentation is an annoyance for any project. I've kept the official docs up to date, but there are so many blog posts out there that point people towards methods that don't work any more; there's not much that can be done about that. Just pay attention to the posting date when you are looking for things like this; if you find a post that's over six months old you might need to think twice. -Phil -- You 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/SLIME/Emacs questions
On Jan 1, 1:45 pm, Phil Hagelberg p...@hagelb.org wrote: You can get this to work, but as you can see it's very manual and error-prone. The basicslimeREPL is working using automated installation from ELPA. I am using the ELPA installation method, it's working well via the automatic install. Thank you for providing this. The installed packages: clojure-mode-1.6 slime-20091016 slime-repl-20091016 swank-clojure-1.1.0 include snapshots of slime and slime/contrib/slime-repl.el. Will these be merged with upstream slime soon? I would like to track the repository versions of clojure, clojure- contrib, clojure-mode, slime(-repl) and swank-clojure, using the ELPA configuration as a guide. Thanks Jeff -- You 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: refs, agents and add-watch
I'm using counterclockwise, clojure version 1.1.0. The exception stopped occurring I think I had to recompile the code. I structured the code this way because of the way the problem is formulated (e.g. the owner should be the only one to inc materials etc), yet, the more I look at it the more it seems geared towards C concurrency mechanisms. Also, ask-materials and send-products should be call immediately after a certain threshold. ask-materials != dec, one decrements the other increments and the same for send-products and inc. Thanks for the dumping macro (I knew that macros eliminate code repetition but I didn't knew how to write one). -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: refs, agents and add-watch
I now have another problem. When I run this in the repl: (add-watch products :prodkey send-products) (add-watch material :matkey ask-material) (dump material products products-store) (loop [cnt 10] (map #(send % client-act) clients) (map #(send % manufacture) artisans) (if (zero? cnt) (str done) (recur (dec cnt It just prints done. Where is the output of dump? -- You 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: Seattle Clojure meeting
On Fri, Feb 5, 2010 at 12:50 PM, Phil Hagelberg p...@hagelb.org wrote: Wow, I certainly was not expecting that level of response; this is great. Looks like the 11th (Thursday) is the crowd favorite. Once again, the location is http://bit.ly/c9jinW We'll be meeting in the back. Zoka is a big place, but it can get crowded with all those college students around, so I'll try to save some space. Look for the laptop with the my other car is a cdr sticker, or for me; my photo is at http://technomancy.us/colophon Just a reminder: this is tonight. I'd love to see you there. -Phil -- You 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: Simple clojure and contrib install, with SLIME ... ?
Paul, I first struggled to find a way to do everything manually cause I didn't like someone else's self installer messing up my distributions setup. I think I've found a satisfactory hybrid approach to setup my IDE on any machine now in 4 chunked steps. 1. I rely on the distro to install emacs, slime, and git, and the base system we would expect on a *nix machine. 2. I then bootstrap a checkouted out leiningen. -Download stable lein script (see Phil's github readme) and rename it to lein-stable, put it in path -git clone developers version (I actually checkout my own fork that has some modifications to swank-clojure and lein-swank plugin. This makes it easy to deploy and it includes any potential new plugins I would write. I build the jar for swank-clojure) -run lein-stable deps in the checkout directory. Symlink checkedout lein script to path. -if you ever want to use a custom version of some clojure lib, check it out, reversion it, and run lein install to put it in the local repo 3. I setup my .emacs for clojure -Link clojure-mode and swank-clojure (add-to-list 'load-path ~/clj/clojure-mode) (require 'clojure-mode) (add-to-list 'load-path ~/clj/emacs-slime/swank-clojure) (require 'swank-clojure) 4. Connect to a running swank-server -create a new project directory with a swank-clojure as a dependency in the project.clj -run lein swank -in emacs M-x slime-connect Hopefully that might give you some ideas. Best, Brent On Feb 11, 1:59 pm, Paul Mooser taron...@gmail.com wrote: I struggle fairly often with keeping clojure/contrib/slime up to date on my machine - it seems that every time I update it, something fundamental has broken (like build.xml going away in contrib). There are a few things that seem to try to make this easier (like clojure- mode's install-clojure, or ClojureX) but they also seem unable to keep up with the speed of some of the changes that are happening (or, quite possibly, I'm using them incorrectly or ineffectively). What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? Thanks for any help! -- You 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: small code review..
On 12 February 2010 03:19, Martin Hauner martin.hau...@gmx.net wrote: I'm mostly interested if there is anything in my code one would/should never do that way. Looks excellent, you've aced it! I'd like to discuss switching... You wrote: (cond (empty? rolls) 0 (strike? rolls)(+ (score-strike rolls) (score-after-strike rolls)) (spare? rolls)(+ (score-spare rolls) (score-after-frame rolls)) (more? rolls)(+ (score-frame rolls) (score-after-frame rolls))) Which is correct and very readable. If I wanted a DRYer expression: (condp #(%1 %2) rolls empty? 0 strike?(+ (score-strike rolls) (score-after-strike rolls)) spare?(+ (score-spare rolls) (score-after-frame rolls)) more?(+ (score-frame rolls) (score-after-frame rolls))) But the #(%1 %2) is ugly and not immediately obvious how it works. Would it be any nicer if we defined a function-name? or made a switchp which hides that part? Or use a trick: (condp apply [rolls] ) I've found myself faced with this particular DRY vs clear trade-off and never been sure what to do! Regards, Tim. -- You 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: Simple clojure and contrib install, with SLIME ... ?
Sadly, it looks like trying to follow the ELPA instructions to get package.el going on my emacs (carbon emacs) on the Mac doesn't actually work - I'll have to debug into it later to figure out what's actually going on, but unfortunately, for now, it's another dead end. On Feb 11, 1:59 pm, Paul Mooser taron...@gmail.com wrote: Thanks a lot for your reply, Phil - I had no idea it was deprecated. I'll make an effort to do what you've suggested! -- You 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: refs, agents and add-watch
On 12 February 2010 10:22, MiltondSilva shadowtr...@gmail.com wrote: (add-watch products :prodkey send-products) (add-watch material :matkey ask-material) (dump material products products-store) (loop [cnt 10] (map #(send % client-act) clients) (map #(send % manufacture) artisans) (if (zero? cnt) (str done) (recur (dec cnt It just prints done. Where is the output of dump? Lazy map strikes again! Use doseq instead of map. (map f coll) returns a lazy sequence which is not evaluated unless used. If you want side-effects (like send) you need to force the execution. -- You 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: refs, agents and add-watch
(e.g. the owner should be the only one to inc materials etc) What's so special about the inc function as opposed to any other function? Also, ask-materials and send-products should be call immediately after a certain threshold. ask-materials != dec, one decrements the other increments and the same for send-products and inc. My point is it seems like there should be one function that contains some algorithm for how to modify the state of the ref, rather than using inc and having more rules orthogonally injected via add-watch. Thanks for the dumping macro (I knew that macros eliminate code repetition but I didn't knew how to write one). Note you could do something similar with a function, but using a macro lets me print out the name of the ref. -- You 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: refs, agents and add-watch
On Feb 11, 4:22 pm, MiltondSilva shadowtr...@gmail.com wrote: I now have another problem. When I run this in the repl: (add-watch products :prodkey send-products) (add-watch material :matkey ask-material) (dump material products products-store) (loop [cnt 10] (map #(send % client-act) clients) (map #(send % manufacture) artisans) (if (zero? cnt) (str done) (recur (dec cnt It just prints done. Where is the output of dump? map is lazy. -- You 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: small code review..
On Feb 11, 4:34 pm, Timothy Pratley timothyprat...@gmail.com wrote: On 12 February 2010 03:19, Martin Hauner martin.hau...@gmx.net wrote: I'm mostly interested if there is anything in my code one would/should never do that way. Looks excellent, you've aced it! I'd like to discuss switching...You wrote: (cond (empty? rolls) 0 (strike? rolls) (+ (score-strike rolls) (score-after-strike rolls)) (spare? rolls) (+ (score-spare rolls) (score-after-frame rolls)) (more? rolls) (+ (score-frame rolls) (score-after-frame rolls))) Which is correct and very readable. If I wanted a DRYer expression: (condp #(%1 %2) rolls empty? 0 strike? (+ (score-strike rolls) (score-after-strike rolls)) spare? (+ (score-spare rolls) (score-after-frame rolls)) more? (+ (score-frame rolls) (score-after-frame rolls))) But the #(%1 %2) is ugly and not immediately obvious how it works. Would it be any nicer if we defined a function-name? or made a switchp which hides that part? Or use a trick: (condp apply [rolls] ) I've found myself faced with this particular DRY vs clear trade-off and never been sure what to do! Regards, Tim. And the minute you change cond to be more terse someone will decide that one of the conditions needs to factor in some other param, thus breaking the pattern. ;) -- You 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/SLIME/Emacs questions
On Thu, Feb 11, 2010 at 1:20 PM, Jeff Kowalczyk jeff.kowalc...@gmail.com wrote: The installed packages: clojure-mode-1.6 slime-20091016 slime-repl-20091016 swank-clojure-1.1.0 include snapshots of slime and slime/contrib/slime-repl.el. Will these be merged with upstream slime soon? I spoke with the slime maintainers about merging my changes, but they weren't interested. The changes were pretty minor though. I would like to track the repository versions of clojure, clojure- contrib, clojure-mode, slime(-repl) and swank-clojure, using the ELPA configuration as a guide. Upstream slime is not compatible with swank-clojure, so unless you do a lot of CL work I would strongly recommend against this. There have been a number of threads discussing this in the past; if you're interested in fixing this I could provide further information. -Phil -- You 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: Simple clojure and contrib install, with SLIME ... ?
Michael, I'm not sure of the full feature list of leiningen but since it maintains a local repo, there might be a way (or if not, it should be added) to install locally built libs and clojure versions (projects normally without project.clj files). Perhaps there is a way to add that information (by writing a special case project.clj file that's handled differently) so that every person can have their own local repository for ALL clojure software? To rephrase another way, have it so that leiningen, in some projects, at most slaps a version number on a jar and copies/installs it in the repo. In my opinion, leiningen is still a long ways from being perfect, but I think its good enough to be the package manager for clojure. Another way to put it, instead of rolling your own package manager, you should just fork leiningen. I could be wrong though... For me, at least, it fulfills a lot of the common cases. On Feb 11, 4:01 pm, Michael Wood esiot...@gmail.com wrote: On 11 February 2010 21:07, Richard Newman holyg...@gmail.com wrote: What are other people doing to maintain their installations? Is there some simple way to keep all of these projects up to date? Or do people simply not update all of these projects often? I suck it up. Fortunately I was in the process of switching to Leiningen when contrib suddenly moved to Maven, but I can't say I like it -- IMO there was nothing wrong with ant for contrib, which has no dependencies! I must say that I *hate* it when I just want to compile something and the bloody build system decides to download a bunch of crap. Especially when it worked fine without all of that before. And then it wants to download clojure-something-SNAPSHOT.jar when I have it compiled locally already! The recent packaging thread did give me some hope that maybe Maven was not such a bad idea, but it's yet another thing to learn because I don't like the defaults of wasting my precious bandwidth and time. Sorry for the rant :) -- Michael Wood esiot...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en