Re: Question about future
Please also note the existence of (future-call), which takes a no-arg fn instead of a body, HTH, -- Laurent On 25 nov, 17:21, David Brown cloj...@davidb.org wrote: On Tue, Nov 24, 2009 at 09:04:38PM -0800, Hong Jiang wrote: Hi all, I'm new to Clojure and playing with small programs. Today I wrote a snippet to figure out how future works: (defn testf [] (let [f (future #(do (Thread/sleep 5000) %) 5) g 7] (+ g @f))) You don't ever evaluate the function containing the sleep, you just create it, and then immediately return 5. Future contains an explicit do, so you can just do the steps in the future: [f (future (Thread/sleep 5000) 5) ... Or, if you want to get the function call in, you'll need to call it: [f (future (#(do (Thread/sleep 5000) %) 5)) ...] David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Where is the Clojure 1.0 API documentation?
I just noticed that the API link on the clojure web site brings up documentation for the master branch of Clojure instead of 1.0.0. I can't find the 1.0.0 docs anywhere either. This is obviously a problem for 1.0.0 users, since the docs refer to features that don't exist. I think it would be good to have the API page contain links to 1.0.0 docs as well as master and perhaps other branches as well. Also, a clear indication (preferably in a bold font or something) of which revision the doc was generated for would be useful. -- Jarkko -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how 'bout a debug-repl?
Awesome! I've googled high and low for exactly this functionality in the past. +1 for getting this into core or contrib if it could work there. Can you wrap a require to make a whole library debuggable? (with-lexical-frames (require 'foo.bar)) It would be very handy to have a debug mode where exceptions automatically drop you into a repl with all of the associated environment for you to explore. I guess something ala Smalltalk systems... -Jeff On Dec 7, 9:37 pm, George Jahad cloj...@blackbirdsystems.net wrote: Every time I stick a println into some Clojure code to debug it, I think to myself, This is Lisp! I should be able to insert a repl here! The problem is of course that Clojure's eval function doesn't know about the surrounding lexical scope. So I started asking myself, what is the simplest change I could make to Clojure to support an eval that understands that scope? Then I tried to implement it. Basically, here's what I came up with. 1. Modify the Clojure compiler so that when a flag is turned on, it stores references to the lexical scope in a dynamic var. Thus, each time the compiler creates a new lexical scope, it also emits the byte code to push a hash-map with the details onto the var. When that scope ends, the byte code for popping the hash-map off the var is emitted. 2. Then in Clojure proper, add a special version of eval that uses that var. It wraps the form being eval'ed in a let that emulates the original lexical scope, something like this: `(eval (let [~@(make-let-bindings (:lexical-frames (var-get (resolve context] ~form)) With those two pieces, it's straight-forward creating a debug-repl that understands the surrounding lexical scope. I'm pretty pleased with the results and wanted to show them off. More details here:http://georgejahad.com/clojure/debug-repl.html Thanks to the my coworkers, the Sonian-Clojure Brain Trust, for their support and encouragement! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how 'bout a debug-repl?
George Jahad cloj...@blackbirdsystems.net writes: Every time I stick a println into some Clojure code to debug it, I think to myself, This is Lisp! I should be able to insert a repl here! The problem is of course that Clojure's eval function doesn't know about the surrounding lexical scope. So I started asking myself, what is the simplest change I could make to Clojure to support an eval that understands that scope? Then I tried to implement it. Neat idea. Unless I'm misunderstanding what your modifications do, I've come up with a simple pure macro version that doesn't require any modifications to Clojure. It also works fine in the middle of lets and such and you can put a call to the (local-bindings) macro anywhere to get a map of the locals to their symbols. http://gist.github.com/252421 Cheers, Alex -- You 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: Where is the Clojure 1.0 API documentation?
I second this - since many of the IDE plugins bundle the clojure-1.0 jar, new users trying out Clojure (and IDEs) can't use all the features listed in the docs, and it's hard to tell which is which. Maybe we could at least add a 'added in version' to the new method metadata? On Dec 9, 4:48 am, Jarkko Oranen chous...@gmail.com wrote: I just noticed that the API link on the clojure web site brings up documentation for the master branch of Clojure instead of 1.0.0. I can't find the 1.0.0 docs anywhere either. This is obviously a problem for 1.0.0 users, since the docs refer to features that don't exist. I think it would be good to have the API page contain links to 1.0.0 docs as well as master and perhaps other branches as well. Also, a clear indication (preferably in a bold font or something) of which revision the doc was generated for would be useful. -- Jarkko -- You 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: Where is the Clojure 1.0 API documentation?
Enhancing the doc tool so that we have versions for the multiple branches (1.0, 1.1, master, new) is on my agenda. Maybe there's a way that Rich could add a link to the old 1.0 doc in the meantime. I think that the added in version metadata tag is a good idea, at least for clojure itself. Python does this and I've always liked it. Tom On Dec 9, 5:43 am, Mark Tomko mjt0...@gmail.com wrote: I second this - since many of the IDE plugins bundle the clojure-1.0 jar, new users trying out Clojure (and IDEs) can't use all the features listed in the docs, and it's hard to tell which is which. Maybe we could at least add a 'added in version' to the new method metadata? On Dec 9, 4:48 am, Jarkko Oranen chous...@gmail.com wrote: I just noticed that the API link on the clojure web site brings up documentation for the master branch of Clojure instead of 1.0.0. I can't find the 1.0.0 docs anywhere either. This is obviously a problem for 1.0.0 users, since the docs refer to features that don't exist. I think it would be good to have the API page contain links to 1.0.0 docs as well as master and perhaps other branches as well. Also, a clear indication (preferably in a bold font or something) of which revision the doc was generated for would be useful. -- Jarkko -- You 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: Embedding a REPL
Hey thanks to everyone who replied to this thread; I appreciate all the ideas. I managed to get my version working by closing *in*...but I had to use my own code to start the repl, because main uses code that calls System/exit after the repl completes (bad). It turns out my (our...I didn't do it!) wrapper around System.in wasn't implementing close() properly, so infinite calls to read(...) occurred subsequently. Thanks again everybody! Mike On Dec 8, 6:28 pm, Liam liam.ga...@gmail.com wrote: Close the *out* stream, not the *in*. That should do it. (. *out* close) It was fun watching that the first time it happend to me. ;-) On Dec 8, 11:26 am, Mike cki...@gmail.com wrote: I tried this approach, and it works great. I had to spin the call to main.main() in another thread, but that's expected. What I didn't expect is that when I try to close the LineNumberingPushbackReader (to end the repl), I get infinite exceptions: java.io.IOException: Stream closed java.io.IOException: Stream closed java.io.IOException: Stream closed ... It appears that somewhere in the repl loop it's trying to do a read (or possibly unread in skip-whitespace?), printing the exception, but then not registering that it should exit, and then keeps trying to read again. I haven't really followed the code to see where the problem lies, but let me pose this question anyways: what's the best way to close the repl? I can't call (System/exit 0), 'cause the whole thing will come down. I thought calling LNPR.close() on the input Reader would be like sending Ctrl-D to the console, but either I'm doing it wrong or that doesn't work for some reason. Any ideas? I love this simple approach, I didn't have to munge hardly any code (I had been traveling down the replace :read and :print and :prompt and :flush and... path, and it wasn't as pretty as I hoped). Thanks in advance... Mike On Dec 7, 7:26 pm, Liam liam.ga...@gmail.com wrote: I think the following is “looked down upon” or “discouraged“, but I managed to sift through how clojure itself handles its own stuff in java and I came up with the following. Say, that you want to set *out*, *in*, and *err* in clojure to something from Java before starting a REPL. Here is how I passed on these values to the clojure RT: try { Var.pushThreadBindings(RT.map( RT.OUT, new OutputStreamWriter(MYout), RT.IN, new LineNumberingPushbackReader(new InputStreamReader(MYin)), RT.ERR, new PrintWriter(new OutputStreamWriter(MYout), true))); main.main(new String[] {-r}); } catch (Exception e) {} finally { Var.popThreadBindings(); } Don’t forget to import (after setting clojure.jar on the cp). import clojure.main; import clojure.lang.RT; import clojure.lang.Var; Note that the doc-string of the clojure (repl function allows for hooks for some of what you want. You just need to look into how you could pass on those functions for :need- prompt, :prompt, :flush, :read in a way that clojure can digest, which I think is just a Runnable in a map of sorts. But you’ll have to look into that to be sure. Regardless, I highly recommend that you separate Java from clojure coding as mush as possible, or at least treat clojure in a functional way when touching it from Java. I hope this helps. If someone else has a better way, I’m all ears. On Dec 7, 8:19 am, Mike cki...@gmail.com wrote: I've seen an example of launching a Clojure script from Java (http:// en.wikibooks.org/wiki/Clojure_Programming/ Tutorials_and_Tips#Invoking_Clojure_from_Java), but I've got an application in which I'd like to run a REPL. My app has its own JPanel for display results, and a text area for input, so I'll need to start repl with some replacement callback functions (read, print, prompt, need-prompt). I'd like to code as much as possible in Clojure, but at some point I need to pass in some Java object instances that my wrapper functions will use to perform I/ O for the repl. Has anyone done this recently? Could someone point me in the right direction for exposing Java objects into Clojure? I've tried reading main.java and RT.java looking for hints, but I'm not too smart yet about the Clojure environment, the scope of when things live, and such. Thanks in advance for any hints... Mike- 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: Datatypes and protocols - update
On Mon, 07 Dec 2009 12:07:12 -0500, Laurent PETIT laurent.pe...@gmail.com wrote: 2009/12/7 Hugo Duncan hugodun...@users.sourceforge.net On Mon, 07 Dec 2009 06:53:38 -0500, Rich Hickey richhic...@gmail.com wrote: Yes, methods are not really functions. Thinking about them as closures over the object is a good way to go - you can see that analogy in play when you consider recur, which works with these methods, but could not rebind 'this'. The recur case sealed the deal in the decision not to include 'this' in the argument lists. I had a quick play with protocols, and the biggest problem I had getting started was realising that the signature of a method definition in defprotocol was different to the signature required to implement the same method in deftype. FWIW, I found it very non-intuitive. And now that you've got it, do you still feel this non-intuitive. Because I had the same feeling first: I thought I would never rembember how things work and why put 'this-like args there, and not there ... But now that everything clicked in place, I feel the last status of what Rich achieved to do the most natural and intuitive. I'll no doubt get used to it :-) A couple of things that would have helped me get it: From the deftype doc: Thus methods for protocols will take one fewer arguments than do the protocol functions. would (at least for me) be clearer as: Thus methods for protocols are implemented with one fewer argument than in the protocol function definitions. The example of a deftype protocol implementation that is in the defprotocol doc string could be repeated in the deftype doc string. Basically, what helped me was along the lines of what Konrad said : * defprotocol and extend are purely functional : so you have to specify every argument, including the object the functions acts upon. * deftype with embedded protocol definition for the type, or reify, in the contrary, do not define pure functions. They define methods. You cannot get them as values and pass them around like higher-order functions, for example. And you must know this fact, it cannot be an implementation detail. So, since you know this fact, you remember that you're in a method definition (in the general sense of object oriented languages : method of a class) and, as you do with e.g. java, C#, ... , when definining methods, you do not add the target of the method as an implicit argument. The big advantage I see to this is that once you get it, you don't have anymore to remember where 'this is explicit and where it's implicit: it's intuitive. The other big advantage is that the use of recur inside these functions/methods bodies continue to match exactly the signature of the function/method (otherwise you would have had to remember that, e.g. in methods defined via deftype, you must place an explicit this argument in the method arg list, but not place it in the recur calls ... :-( ) That explanation certainly helps describe and clarify the reasons for the difference. I still find it counter-intuitive that the definition follows the syntax of the functional world, and the implementation that of an object orientated world. However, I can't think of any suggestion to resolve this, and as you say it does reflect the reality of the situation, so I'll get used to it :-) -- Hugo Duncan -- You 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
Question about The whole language is there, all of the time.
Hi, I've been rereading Programming Clojure and on page 25 it says The whole language is there, all the time. Paul Graham's essay Revenge of the Nerds explains why this is so powerful. So, I read Paul Graham's essay, and the relevant section seems to be The whole language there all the time. There is no real distinction between read-time, compile-time, and runtime. You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime. Running code at read-time lets users reprogram Lisp's syntax; running code at compile-time is the basis of macros; compiling at runtime is the basis of Lisp's use as an extension language in programs like Emacs; and reading at runtime enables programs to communicate using s-expressions, an idea recently reinvented as XML. The part Running code at read-time lets users reprogram Lisp's syntax caught my attention. Is this talking about reader macros? I believe I read that clojure doesn't have reader macros, so would it be more accurate to say The whole language is there, _most_ of the time? Just curious, 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: Question about The whole language is there, all of the time.
I would say it depends how strongly you feel about reader macros, since they are purely (very useful) shorthand. On Dec 9, 11:03 am, Jeff Dik s45...@gmail.com wrote: Hi, I've been rereading Programming Clojure and on page 25 it says The whole language is there, all the time. Paul Graham's essay Revenge of the Nerds explains why this is so powerful. So, I read Paul Graham's essay, and the relevant section seems to be The whole language there all the time. There is no real distinction between read-time, compile-time, and runtime. You can compile or run code while reading, read or run code while compiling, and read or compile code at runtime. Running code at read-time lets users reprogram Lisp's syntax; running code at compile-time is the basis of macros; compiling at runtime is the basis of Lisp's use as an extension language in programs like Emacs; and reading at runtime enables programs to communicate using s-expressions, an idea recently reinvented as XML. The part Running code at read-time lets users reprogram Lisp's syntax caught my attention. Is this talking about reader macros? I believe I read that clojure doesn't have reader macros, so would it be more accurate to say The whole language is there, _most_ of the time? Just curious, 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: Where is the Clojure 1.0 API documentation?
It (or something similar) is present in some of Sun's Javadocs, if I recall correctly, and I frequently found it useful, because I kept a bookmark on the 1.6 javadocs but sometimes had to write for 1.5 JVMs. Mark On Dec 9, 10:10 am, Tom Faulhaber tomfaulha...@gmail.com wrote: Enhancing the doc tool so that we have versions for the multiple branches (1.0, 1.1, master, new) is on my agenda. Maybe there's a way that Rich could add a link to the old 1.0 doc in the meantime. I think that the added in version metadata tag is a good idea, at least for clojure itself. Python does this and I've always liked it. Tom On Dec 9, 5:43 am, Mark Tomko mjt0...@gmail.com wrote: I second this - since many of the IDE plugins bundle the clojure-1.0 jar, new users trying out Clojure (and IDEs) can't use all the features listed in the docs, and it's hard to tell which is which. Maybe we could at least add a 'added in version' to the new method metadata? On Dec 9, 4:48 am, Jarkko Oranen chous...@gmail.com wrote: I just noticed that the API link on the clojure web site brings up documentation for the master branch of Clojure instead of 1.0.0. I can't find the 1.0.0 docs anywhere either. This is obviously a problem for 1.0.0 users, since the docs refer to features that don't exist. I think it would be good to have the API page contain links to 1.0.0 docs as well as master and perhaps other branches as well. Also, a clear indication (preferably in a bold font or something) of which revision the doc was generated for would be useful. -- Jarkko -- You 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: Question about The whole language is there, all of the time.
Jeff Dik wrote: The part Running code at read-time lets users reprogram Lisp's syntax caught my attention. Is this talking about reader macros? I believe I read that clojure doesn't have reader macros, so would it be more accurate to say The whole language is there, _most_ of the time? Clojure does have reader macros, though they're implemented in Java at the moment (because the reader is, too.) They're also reserved for the implementation, though this may change in the future, if someone can convince Rich that an user-augmentable reader provides enough benefits to outweigh the potential problems. -- Jarkko -- You 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: Question about The whole language is there, all of the time.
On Wed, Dec 9, 2009 at 11:15 AM, Jarkko Oranen chous...@gmail.com wrote: Jeff Dik wrote: The part Running code at read-time lets users reprogram Lisp's syntax caught my attention. Is this talking about reader macros? I believe I read that clojure doesn't have reader macros, so would it be more accurate to say The whole language is there, _most_ of the time? Clojure does have reader macros, though they're implemented in Java at the moment (because the reader is, too.) They're also reserved for the implementation, though this may change in the future, if someone can convince Rich that an user-augmentable reader provides enough benefits to outweigh the potential problems. There are certainly lots of good reasons not to include reader macros in the Clojure (e.g. it raises the bar significantly for people writing editors and other tools). But it would be useful if someone were to maintain a fork of Clojure that adds reader-macro capability, and let the community play with it for a while: sort of the way that the bleeding-edgers are playing now with protocols and deftypes on the 'new' branch. The experimentation might bear some interesting fruit. Best, Graham -- Jarkko -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how 'bout a debug-repl?
Brilliant. With such a simple change, I think we just revolutionized the way people debug Clojure. (They just don't realize it yet.) On Dec 9, 3:46 am, Alex Osborne a...@meshy.org wrote: Neat idea. Unless I'm misunderstanding what your modifications do, I've come up with a simple pure macro version that doesn't require any modifications to Clojure. It also works fine in the middle of lets and such and you can put a call to the (local-bindings) macro anywhere to get a map of the locals to their symbols. http://gist.github.com/252421 Cheers, Alex -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
How to internally refer to other keys in a hashmap?
Hi all, I want to make a hash-map where the value of one key depends on the values of other keys in the hash-map. Is there a way to do this, without needing an external reference to the hash-map? {:a 1 :b 2 :c #(+ :a :b)} Similarly, when filling a struct, I often want to refer to the bits I already have filled in. I solve that now by just embedding the (struct mything.. in a let, and just use the serial nature of let to calculate for example c from a and b. Is there a way that while filling a struct I can refer to it? I would like to do this (defstruct virus :epitopes :mutations :viral_load) (def myvirus (struct virus 3 5 (+ (* 0.1 :epitopes) (* 0.2 :mutations Instead of (defstruct virus :epitopes :mutations :viral_load) (let [epitopes 3 mutations 5 viral_load (+ (* 0.1 epitopes) (* 0.2 mutations))] (def myvirus (struct virus epitopes mutations viral_load)) As you can see there is some room for being more concise and compact if you can refer to keys in the same hash-map or struct, even if the hash-map / struct is still being constructed. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how 'bout a debug-repl?
On 9 Dec 2009, at 18:59, George Jahad wrote: Brilliant. With such a simple change, I think we just revolutionized the way people debug Clojure. (They just don't realize it yet.) I for one do - this is an excellent improvement, and I hope that Clojure IDEs will integrate similar tools into their debuggers. I'd love to be able to single-step through my code and have a REPL in the current environment at any time! Konrad (used to WingIDE for Python, which has such functionality) -- You 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 recreating OS X Leiningen 1.0 +Swank bug
I found a solution to this problem and patched my own fork of Leiningen: http://github.com/swannodette/leiningen/commit/9d79d631a9faa870a9347992f50a4312170fdf97 The important thing to do if you want this to work is to closely follow the instructions for hacking on Leiningen that's currently available on GitHub. Then you need a custom-build of lein-swank. This is easy enough to do, move into lein-swank in your Leiningen checkout and run: lein uberjar You might see some errors but none are deal breakers. Copy the new lein-swank-standalone.jar and replace the one in that is in your lib folder in your leiningen checkout. David On Tue, Dec 8, 2009 at 11:35 AM, David Nolen dnolen.li...@gmail.com wrote: Just want to make sure other people are seeing this on OS X. When starting up lein swank from the project directory and attempting to connect from Emacs with slime-connect with this simple clojure project http://github.com/swannodette/lein-macosx-bug (just creates a JPanel and draws a small line) I get an exception: Cannot load apple.laf.AquaLookAndFeel I'm using lein 1.0, usual Emacs/Clojure/SLIME config on OS X 10.6, JDK 1.6 64bit. I note that if I use leiningen from git checkout I don't have this problem which seems odd since there aren't many changes between 1.0 and leiningen/master. Thanks, David -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
On Dec 9, 10:20 am, bOR_ boris.sch...@gmail.com wrote: Hi all, I want to make a hash-map where the value of one key depends on the values of other keys in the hash-map. Is there a way to do this, without needing an external reference to the hash-map? {:a 1 :b 2 :c #(+ :a :b)} Similarly, when filling a struct, I often want to refer to the bits I already have filled in. I solve that now by just embedding the (struct mything.. in a let, and just use the serial nature of let to calculate for example c from a and b. Is there a way that while filling a struct I can refer to it? I would like to do this (defstruct virus :epitopes :mutations :viral_load) (def myvirus (struct virus 3 5 (+ (* 0.1 :epitopes) (* 0.2 :mutations Instead of (defstruct virus :epitopes :mutations :viral_load) (let [epitopes 3 mutations 5 viral_load (+ (* 0.1 epitopes) (* 0.2 mutations))] (def myvirus (struct virus epitopes mutations viral_load)) As you can see there is some room for being more concise and compact if you can refer to keys in the same hash-map or struct, even if the hash-map / struct is still being constructed. Do you expect that modifying the values of :epitopes or :mutations should be reflected in the value of :viral_load? If not, then you could just write a custom function that creates virus instances instead of using struct, e.g.: (defn viral-load [epitopes mutations] (+ (* 0.1 epitopes) (* 0.2 mutations))) (defn make-virus [epitopes mutations] (struct virus epitopes mutations (viral-load epitopes mutations))) If you *do* want :viral_load to reflect changes in the other values, then I'd say you shouldn't include it in the struct. Actually, either way this seems to be a caching mechanism which is both orthogonal to the domain, and tends to be more trouble than it's worth in the long run. In short, smells like OO instead of FP, but I could be wrong. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
I expect that each time I call :viral_load, it takes whatever value :epitopes or :mutations has at that point in time, so I can indeed write a function outside of the map that does the calculation, but I found the idea of an embedded function neat. This works as long as there is just one function in the model that describes how epitopes and mutations translates to viral load. However, if you would want to do something like an evolvable trade-off between epitopes and mutations in viruses, you would like to be able to store the functions inside each virus. On Dec 9, 8:40 pm, ataggart alex.tagg...@gmail.com wrote: On Dec 9, 10:20 am, bOR_ boris.sch...@gmail.com wrote: Hi all, I want to make a hash-map where the value of one key depends on the values of other keys in the hash-map. Is there a way to do this, without needing an external reference to the hash-map? {:a 1 :b 2 :c #(+ :a :b)} Similarly, when filling a struct, I often want to refer to the bits I already have filled in. I solve that now by just embedding the (struct mything.. in a let, and just use the serial nature of let to calculate for example c from a and b. Is there a way that while filling a struct I can refer to it? I would like to do this (defstruct virus :epitopes :mutations :viral_load) (def myvirus (struct virus 3 5 (+ (* 0.1 :epitopes) (* 0.2 :mutations Instead of (defstruct virus :epitopes :mutations :viral_load) (let [epitopes 3 mutations 5 viral_load (+ (* 0.1 epitopes) (* 0.2 mutations))] (def myvirus (struct virus epitopes mutations viral_load)) As you can see there is some room for being more concise and compact if you can refer to keys in the same hash-map or struct, even if the hash-map / struct is still being constructed. Do you expect that modifying the values of :epitopes or :mutations should be reflected in the value of :viral_load? If not, then you could just write a custom function that creates virus instances instead of using struct, e.g.: (defn viral-load [epitopes mutations] (+ (* 0.1 epitopes) (* 0.2 mutations))) (defn make-virus [epitopes mutations] (struct virus epitopes mutations (viral-load epitopes mutations))) If you *do* want :viral_load to reflect changes in the other values, then I'd say you shouldn't include it in the struct. Actually, either way this seems to be a caching mechanism which is both orthogonal to the domain, and tends to be more trouble than it's worth in the long run. In short, smells like OO instead of FP, but I could be wrong. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
I expect that each time I call :viral_load, it takes whatever value :epitopes or :mutations has at that point in time, I can indeed write a function outside of the map that does the calculation, but I found the idea of an embedded function neat. Also writing a function only works as long as there is a limited number of functions in the model that describes how epitopes and mutations translates to viral load. However, if you would want to do something like an evolvable trade-off between epitopes and mutations in viruses, you would like to be able to store the functions inside each virus. On Dec 9, 8:40 pm, ataggart alex.tagg...@gmail.com wrote: On Dec 9, 10:20 am, bOR_ boris.sch...@gmail.com wrote: Hi all, I want to make a hash-map where the value of one key depends on the values of other keys in the hash-map. Is there a way to do this, without needing an external reference to the hash-map? {:a 1 :b 2 :c #(+ :a :b)} Similarly, when filling a struct, I often want to refer to the bits I already have filled in. I solve that now by just embedding the (struct mything.. in a let, and just use the serial nature of let to calculate for example c from a and b. Is there a way that while filling a struct I can refer to it? I would like to do this (defstruct virus :epitopes :mutations :viral_load) (def myvirus (struct virus 3 5 (+ (* 0.1 :epitopes) (* 0.2 :mutations Instead of (defstruct virus :epitopes :mutations :viral_load) (let [epitopes 3 mutations 5 viral_load (+ (* 0.1 epitopes) (* 0.2 mutations))] (def myvirus (struct virus epitopes mutations viral_load)) As you can see there is some room for being more concise and compact if you can refer to keys in the same hash-map or struct, even if the hash-map / struct is still being constructed. Do you expect that modifying the values of :epitopes or :mutations should be reflected in the value of :viral_load? If not, then you could just write a custom function that creates virus instances instead of using struct, e.g.: (defn viral-load [epitopes mutations] (+ (* 0.1 epitopes) (* 0.2 mutations))) (defn make-virus [epitopes mutations] (struct virus epitopes mutations (viral-load epitopes mutations))) If you *do* want :viral_load to reflect changes in the other values, then I'd say you shouldn't include it in the struct. Actually, either way this seems to be a caching mechanism which is both orthogonal to the domain, and tends to be more trouble than it's worth in the long run. In short, smells like OO instead of FP, but I could be wrong. -- You 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
old thread bump: dialyzer?
anybody working on something like erlang's dialyzer static checking tool? a guy can hope... -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: how 'bout a debug-repl?
Clojure IDEs will integrate similar tools into their debuggers. I'd love to be able to single-step through my code and have a REPL in the current environment at any time! yes, catching up with what i assume CL can do would rock :-) -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
However, if you would want to do something like an evolvable trade-off between epitopes and mutations in viruses, you would like to be able to store the functions inside each virus. And you can do that if you change how you retrieve values. (defn get-fn Like `get`, but handles returned functions by calling them with the map itself. [m k] (let [x (get m k)] (if (fn? x) (x m) x))) (def my-map {:a 1 :b 2 :c #(+ (:a %) (:b %))}) (get-fn my-map :a) = 1 (get-fn my-map :c) = 3 -- You 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 journal-based persistenсe for Clojure
I see one issue with this approach. If we get rid of locking then some transactions occur reordered in journal files. So simple backuping of journal files can be dangerous. Imagine the case when two transactions are reordered and got into different files: 1.journal: (tr1) ;1 (tr3) ;3 4.journal: (tr4) ;4 (tr2) ;2 So additional script is needed to backup inactive (closed) journal files into a safe set of transactions. What do you think? Is it worth to complicate things this way? On Sat, Dec 5, 2009 at 9:12 PM, Sergey Didenko sergey.dide...@gmail.comwrote: Nice idea, Luc! Useful details, Jon. So I'm implementing (dosync (let [ tr-id (swap! tr-atom inc)] (transaction-itself) and then loading transactions in their tr-id's order in the next release. Probably with some floating window of postponed transactions in order not to load all the transactions into memory at once. Does anybody have reasons in mind why this approach can fail? -- You 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
dot dot (..) notation failing me
If I write: (.setMessage (.getMonitor this) Counting...) and it works, why would (.. this getMonitor setMessage Counting...) give me an IllegalArgumentException: Malformed member expression (count-script.clj:11)? I'm using 1.0.0, if that makes a difference. Sorry if this is a newb question. Mike -- You 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
Main class not found when starting clojure: java -cp clojure.jar clojure.lang.Repl
As I was preparing the post a message requesting help for an error (see below) generated when I entered the quick start suggest, I realized that suggestion is generic, and not technically accurate. java -cp clojure.jar clojure.lang.Repl Many people may give up without realizing that the VERSION specific name of the clojure jar must be substituted instead java -cp clojure_1.0.0.jar clojure.lang.Repl While this is entirely obvious once it has been noticed even once, I figured posting it might help someone else and might suggest editing the QuickStart page recommendation. Message I originally would have posted When running clojure [java -cp clojure.jar clojure.lang.Repl ] the following error is returned: Could not find the main class: clojure.lang.Repl The full display reads: c:\clojurejava -cp clojure.jar clojure.lang.Repl Exception in thread main java.lang.NoClassDefFoundError: clojure/ lang/Repl Caused by: java.lang.ClassNotFoundException: clojure.lang.Repl at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source) Could not find the main class: clojure.lang.Repl. Program will exit. Please tell me what typical things (paths? configs?) to check and fix? -- HerbM -- You 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: dot dot (..) notation failing me
On Dec 9, 7:04 pm, Mike cki...@gmail.com wrote: If I write: (.setMessage (.getMonitor this) Counting...) and it works, why would (.. this getMonitor setMessage Counting...) give me an IllegalArgumentException: Malformed member expression (count-script.clj:11)? It should be: (.. this getMonitor (setMessage Counting)) - 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
Image scaling libraries. Request for recommendations
Hi there. I'm working on a project using compojure and I will need some way of processing uploaded images, mainly to produce thumbnails etc. I need the results to be of reasonable quality, and accept a decent range of input formats as found among standard windows users. That means decent anti-aliasing for the output, conversion of CMYK to RGB, and input and output in JPG, PNG and BMP and possibly GIF and TIFF. I'm not all that knowledgable of the available Java libraries that are out there and I don't know of any native clojure libs for this kind of work, so if any pointers will be appreciated. Bonus points for the following: Easy clojure integration - though I guess most Java libs will work fine. Ability to easily do a bunch of intermediate steps with no unnessary degradation of image quality - I'd rather not have to convert to jpg for each step when I need to do a blur + resize + crop, for instance. Non-java solutions are acceptible but I need it to be portable - with no obvious differences in output or API - across multiple versions of Windows, OS-X and Linux. Some way of dealing with color profiles. This is for now less important, but I've ran into issues with this before and I'd like a solution that really works well when converting from all kinds of sources to the web. Imagemagick would be my fallback, except it has issues with all the above. -- You 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: dot dot (..) notation failing me
On 9 dec, 22:53, James Reeves weavejes...@googlemail.com wrote: It should be: (.. this getMonitor (setMessage Counting)) I think you meant (.. this (getMonitor) (setMessage Counting)) Every method call should be encloded in parentheses. Unless I've misread the docs for .. -- You 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
On adding InputStream/OutputStream support in clojure.contrib.duck-streams
Duck-streams does good job supporting character based readers and writers, but doesn't do such a complete job with byte-oriented I/O using InputStream and OutputStream. (The to-byte-array and copy mutli-methods offer some support, but there's no equivalent to the reader and writer multi-methods.) It occurs to me that we could refactor most of reader into an input-stream multi-method, which could be useful on its own for byte-oriented I/O. The same is true of writer and output-stream. Also, reader and writer produce streams which are buffered, but accept what the JDK defines as default instead of using *buffer-size*. Perhaps that should be changed. input-stream and output-stream should, presumably also produce buffered streams (perhaps only when ( 0 *buffer-size*). Has anyone already begun work on similar changes? I'd be interested in feedback. Perhaps byte-oriented I/O was left out of duck-streams intentionally. In the meantime, I've begun hacking on some private branches of clojure-contrib to explore these ideas. I'll put something up on github if my musings reach a usable state. In a library of my own, I've used stream decorator functions as below to accomplish what hardcoding BufferedReader. into the reader methods does: (- x input-stream reader buffered) This has a nice feel of orthogonality, but I hesitate to incorporate this idea it duck-streams because I'm doubtful that this approach would gel stylistically with the rest of duck-streams. Thoughts? // ben -- You 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: Question about The whole language is there, all of the time.
On 9 dec, 17:03, Jeff Dik s45...@gmail.com wrote: The part Running code at read-time lets users reprogram Lisp's syntax caught my attention. Is this talking about reader macros? I believe I read that clojure doesn't have reader macros, so would it be more accurate to say The whole language is there, _most_ of the time? Clojure doesn't have user-implementable reader macros, but neither does emacs lisp. Reader macros are nice when you need to embed a significantly different looking kind of language - that's why clojure implements regular expressions as a reader macro instead of a function on a string; you'd have to doubly escape every backslash otherwise. But they're mostly only a way to provide syntactic sugar. I think what Paul is +mainly+ talking about in terms of syntax is just plain ordinary macros that can implement short-circuiting and different evalution strategies for readable data, so that you can implement things like (unless ...) yourself, with no (significant) overhead compared to the built in (if), but you'll have to keep to the basic reader constructs (but not evalution rules). This has the advantage of keeping the language simpler to parse and readble for humans too. The other part of the always there is that you can use whatever is already compiled/parsed to construct new macros, so you can build macros on top of each other, and on top of a mix of macros and (user- defined) functions instead of being restricted to the traditional sparseness of C preprocessor macros. -- You 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: dot dot (..) notation failing me
On Dec 9, 10:14 pm, Joost jo...@zeekat.nl wrote: I think you meant (.. this (getMonitor) (setMessage Counting)) Every method call should be encloded in parentheses. Unless I've misread the docs for .. You don't seem to need parentheses for methods with no arguments. e.g. (.. Foo trim toLowerCase) This is consistent with the - macro, so presumably this is deliberate. - 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: Image scaling libraries. Request for recommendations
Java Advanced Imaging is one possibility: libs for each platform here: https://jai.dev.java.net/binary-builds.html Mac OS X ships with it's own version. On Wed, Dec 9, 2009 at 5:11 PM, Joost jo...@zeekat.nl wrote: Hi there. I'm working on a project using compojure and I will need some way of processing uploaded images, mainly to produce thumbnails etc. I need the results to be of reasonable quality, and accept a decent range of input formats as found among standard windows users. That means decent anti-aliasing for the output, conversion of CMYK to RGB, and input and output in JPG, PNG and BMP and possibly GIF and TIFF. I'm not all that knowledgable of the available Java libraries that are out there and I don't know of any native clojure libs for this kind of work, so if any pointers will be appreciated. Bonus points for the following: Easy clojure integration - though I guess most Java libs will work fine. Ability to easily do a bunch of intermediate steps with no unnessary degradation of image quality - I'd rather not have to convert to jpg for each step when I need to do a blur + resize + crop, for instance. Non-java solutions are acceptible but I need it to be portable - with no obvious differences in output or API - across multiple versions of Windows, OS-X and Linux. Some way of dealing with color profiles. This is for now less important, but I've ran into issues with this before and I'd like a solution that really works well when converting from all kinds of sources to the web. Imagemagick would be my fallback, except it has issues with all the above. -- You 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: How to internally refer to other keys in a hashmap?
Thanks. That is a good solution. There's also some work in dev being done on trans and trans* functions, as Sean Devlin pointed out. see: explanation of trans: http://groups.google.com/group/clojure-dev/browse_thread/thread/4b20e40d83095c67# Chouser commenting on trans: http://groups.google.com/group/clojure-dev/browse_thread/thread/9a518c853bfbba8b# for an interesting read, although it makes my head spin a bit trying to follow it. And attagart - you are right, there is a bit of an OO smell on it, which comes from me using hash-maps as both individuals and viruses in agent-based modeling. I'll think about it. On Dec 9, 10:16 pm, Richard Newman holyg...@gmail.com wrote: However, if you would want to do something like an evolvable trade-off between epitopes and mutations in viruses, you would like to be able to store the functions inside each virus. And you can do that if you change how you retrieve values. (defn get-fn Like `get`, but handles returned functions by calling them with the map itself. [m k] (let [x (get m k)] (if (fn? x) (x m) x))) (def my-map {:a 1 :b 2 :c #(+ (:a %) (:b %))}) (get-fn my-map :a) = 1 (get-fn my-map :c) = 3 -- You 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: leiningen javac plugin
This is exactly what I need! Unfortunately, I'm getting the following exception when I run the compile-java task. $ lein compile-java Exception in thread main java.lang.IllegalArgumentException: No method in multimethod 'as-file' for dispatch value: null at clojure.lang.MultiFn.getFn(MultiFn.java:115) at clojure.lang.MultiFn.invoke(MultiFn.java:157) at clojure.contrib.java_utils$file__565.invoke(java_utils.clj:86) at leiningen.compile$find_lib_jars__1085.invoke(compile.clj:29) at leiningen.compile_java$lib_path__543.invoke(compile_java.clj:15) at leiningen.compile_java$compile_java__546.invoke(compile_java.clj: 21) at clojure.lang.Var.invoke(Var.java:359) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.Var.applyTo(Var.java:476) at clojure.core$apply__4379.invoke(core.clj:436) at leiningen.core$_main__4685.doInvoke(core.clj:38) at clojure.lang.RestFn.invoke(RestFn.java:415) at clojure.lang.AFn.applyToHelper(AFn.java:173) at clojure.lang.RestFn.applyTo(RestFn.java:137) at leiningen.core.main(Unknown Source) Poking around a bit, it looks like it might have something to do with the :library-path value that is passed to Leiningen being null. David On Dec 9, 2:53 am, antoniogarrote listasantoniogarr...@gmail.com wrote: A quick and dirty hack to compile java files in clojure projects using leiningen. The clojar is athttp://clojars.org/, the source code at:http://github.com/antoniogarrote/lein-javac Just run $lein compile-java to transforms 'src/**.java' into 'classes/ **.class' I hope someone find it useful. Cheers! -- You 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
component-orientation?
i'm dreaming of having free time to investigate the Lagoona programming language's thoughts wrt good component-orientation in light of Clojure's Protocols et. al.; thought this paper might be of general interest. http://www.cs.jhu.edu/~phf/pub/tr-ics-2003-22.pdf -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
I've run into this problem before also actually. Basically from what I read, self-recursive data-structures are hard to do in an eager functional programming language. I think you have to resort to mutation to handle it nicely. But I would be very happy to be proven wrong. -Patrick -- You 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: dot dot (..) notation failing me
Hi, Am 09.12.2009 um 20:04 schrieb Mike: If I write: (.setMessage (.getMonitor this) Counting...) and it works, why would (.. this getMonitor setMessage Counting...) give me an IllegalArgumentException: Malformed member expression (count-script.clj:11)? Because your .. form is equivalent to (.Counting... (.setMessage (.getMonitor this))) You are missing a pair of quotes: (.. this getMonitor (setMessage Counting...)) Consider using the - macro since it also allows clojure function and macros and not only methods. (- this .getMonitor (.setMessage Counting...)) Sincerely Meikel smime.p7s Description: S/MIME cryptographic signature
Re: dot dot (..) notation failing me
Thanks to everyone who replied, this makes sense (methods with args need separation). I'll check out - too. I appreciate it!!! Mike On Dec 9, 5:02 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, Am 09.12.2009 um 20:04 schrieb Mike: If I write: (.setMessage (.getMonitor this) Counting...) and it works, why would (.. this getMonitor setMessage Counting...) give me an IllegalArgumentException: Malformed member expression (count-script.clj:11)? Because your .. form is equivalent to (.Counting... (.setMessage (.getMonitor this))) You are missing a pair of quotes: (.. this getMonitor (setMessage Counting...)) Consider using the - macro since it also allows clojure function and macros and not only methods. (- this .getMonitor (.setMessage Counting...)) Sincerely Meikel 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: How to internally refer to other keys in a hashmap?
On Wed, Dec 9, 2009 at 5:24 PM, CuppoJava patrickli_2...@hotmail.com wrote: I've run into this problem before also actually. Basically from what I read, self-recursive data-structures are hard to do in an eager functional programming language. I think you have to resort to mutation to handle it nicely. But I would be very happy to be proven wrong. -Patrick PLT Scheme has a construct called shared that makes it easy to construct self-recursive data structures without mutation. It's sort of like a letrec for data: http://docs.plt-scheme.org/reference/shared.html So it's definitely possible to make it easy to write self-recursive data structures in an eager functional programming language without mutation, but I'm not aware of a way to do it in Clojure. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: Possible BUG: NPE
On Dec 7, 9:39 pm, David Nolen dnolen.li...@gmail.com wrote: http://github.com/jochu/swank-clojure/blob/master/src/main/clojure/sw... Is the offending line. It's really hard to reason about it in clojure source code. I see, in jswat debbuger, the root cause of NPE appears around byte code (putfield ...) for a mutual recursive letfn form. Here is a simple way to reproduce it. I did it this time with latest master branch. Can anybody else reproduce it on different OS/JVM version? (ns test.letfn) (defn debug [n] (letfn [(even [n] (if (== n 0) true (odd (- n 1 (odd [n] (if (== n 0) false (even (- n 1] (odd n))) Listening for transport dt_socket at address: Clojure 1.1.0-master-SNAPSHOT user= (require 'test.letfn) nil user= (test.letfn/debug 5) java.lang.NullPointerException (NO_SOURCE_FILE:0) user= (.. *e getCause printStackTrace) java.lang.NullPointerException at test.letfn$debug__17.invoke(letfn.clj:3) at user$eval__4.invoke(NO_SOURCE_FILE:2) at clojure.lang.Compiler.eval(Compiler.java:4642) at clojure.core$eval__5254.invoke(core.clj:2035) at clojure.main$repl__7403$read_eval_print__7415.invoke (main.clj:183) at clojure.main$repl__7403.doInvoke(main.clj:200) at clojure.lang.RestFn.invoke(RestFn.java:426) at clojure.main$repl_opt__7449.invoke(main.clj:254) at clojure.main$main__7484.doInvoke(main.clj:341) at clojure.lang.RestFn.invoke(RestFn.java:402) at clojure.lang.Var.invoke(Var.java:355) at clojure.lang.AFn.applyToHelper(AFn.java:171) at clojure.lang.Var.applyTo(Var.java:476) at clojure.main.main(main.java:37) nil user= macbook-wifi:/ fenghou$ uname -a Darwin macbook-wifi 8.11.1 Darwin Kernel Version 8.11.1: Wed Oct 10 18:23:28 PDT 2007; root:xnu-792.25.20~1/RELEASE_I386 i386 i386 macbook-wifi:/ fenghou$ java -version java version 1.5.0_19 Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_19- b02-306) Java HotSpot(TM) Client VM (build 1.5.0_19-138, mixed mode, sharing) - Feng On Mon, Dec 7, 2009 at 9:34 PM, David Nolen dnolen.li...@gmail.com wrote: Looking at the stacktrace it looks like this is because of swank_fuzzy.clj. I can start up the SLIME Repl no problem, I see your exact same stack trace only if I try to trigger fuzzy completion via C-c TAB. David On Mon, Dec 7, 2009 at 9:24 PM, Feng hou...@gmail.com wrote: On Dec 7, 8:57 pm, David Nolen dnolen.li...@gmail.com wrote: I was getting this as well, but this was before the last 3 commits to new. Did you wipe your old jars and class files and start afresh? Yes, just to make sure not waste Rich's time. I did doubt and triple checks, ant clean, find $HOME -name clojure\*.jar |xargs rm ... I use Jeff's git master clone, not Phil's branch. No magic in emacs. I load everything (clojure-*.jar, swank-clojure/src) in clojure.sh. And always start swank from console repl in screen, then M-x slime- connect. So I'm pretty sure where everything is. David On Mon, Dec 7, 2009 at 8:31 PM, Feng hou...@gmail.com wrote: Hi, After git pull on new branch commit 1da63ad10d2531264e86eb705a10b3cebc9b1067 Author: Rich Hickey richhic...@gmail.com Date: Mon Dec 7 16:44:41 2009 -0500 init CLEAR_SITES Got NPE in slime java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.NullPointerException [Thrown class java.lang.RuntimeException] Backtrace: 0: clojure.lang.LazySeq.sval(LazySeq.java:47) 1: clojure.lang.LazySeq.seq(LazySeq.java:56) 2: clojure.lang.RT.seq(RT.java:440) 3: clojure.core$seq__3970.invoke(core.clj:105) 4: clojure.core$sort__4671.invoke(core.clj:1994) 5: swank.commands.contrib.swank_fuzzy $fuzzy_generate_matchings__1781.invoke(swank_fuzzy.clj:256) 6: swank.commands.contrib.swank_fuzzy $fuzzy_completion_set__1838$fn__1840.invoke(swank_fuzzy.clj:310) 7: swank.commands.contrib.swank_fuzzy$call_with_timeout__1703.invoke (swank_fuzzy.clj:127) 8: swank.commands.contrib.swank_fuzzy $fuzzy_completion_set__1838.invoke(swank_fuzzy.clj:309) 9: swank.commands.contrib.swank_fuzzy $eval__1849$fuzzy_completions__1851.invoke(swank_fuzzy.clj:323) 10: clojure.lang.Var.invoke(Var.java:385) 11: user$eval__2042.invoke(NO_SOURCE_FILE) 12: clojure.lang.Compiler.eval(Compiler.java:5256) 13: clojure.lang.Compiler.eval(Compiler.java:5224) 14: clojure.core$eval__4688.invoke(core.clj:2036) 15: swank.core$eval_in_emacs_package__399.invoke(core.clj:58) 16: swank.core$eval_for_emacs__468.invoke(core.clj:126) 17: clojure.lang.Var.invoke(Var.java:373) 18: clojure.lang.AFn.applyToHelper(AFn.java:182) 19: clojure.lang.Var.applyTo(Var.java:482) 20:
Re: Possible BUG: NPE
Does not happen for me through Slime or raw REPL. user (ns test.letfn) (defn debug [n] (letfn [(even [n] (if (== n 0) true (odd (- n 1 (odd [n] (if (== n 0) false (even (- n 1] (odd n))) #'test.letfn/debug test.letfn (debug 5) true test.letfn (debug 4) false Clojure: 76e7c4317dc3eac80c4908ac5e5fb885e302b2a4 GNU Emacs 22.3.1 (i386-apple-darwin9.7.0, Carbon Version 1.6.0) of 2009-07-25 on gs674-seijiz.local (Hmm, I thought I was running 23!) $ uname -a Darwin wheeljack 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 $ java -version java version 1.6.0_17 Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125) Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode) -- You 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: Possible BUG: NPE
You don't have the locals clearing changes Richard. Rich Hickey, I confirm that this also causes an NPE on my setup. Clojure new branch 6d40a76e8a012909f2d2a594ce66a78318889799 OS X 10.6 JDK 1.6 64bit David On Wed, Dec 9, 2009 at 10:46 PM, Richard Newman holyg...@gmail.com wrote: Does not happen for me through Slime or raw REPL. user (ns test.letfn) (defn debug [n] (letfn [(even [n] (if (== n 0) true (odd (- n 1 (odd [n] (if (== n 0) false (even (- n 1] (odd n))) #'test.letfn/debug test.letfn (debug 5) true test.letfn (debug 4) false Clojure: 76e7c4317dc3eac80c4908ac5e5fb885e302b2a4 GNU Emacs 22.3.1 (i386-apple-darwin9.7.0, Carbon Version 1.6.0) of 2009-07-25 on gs674-seijiz.local (Hmm, I thought I was running 23!) $ uname -a Darwin wheeljack 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 $ java -version java version 1.6.0_17 Java(TM) SE Runtime Environment (build 1.6.0_17-b04-248-9M3125) Java HotSpot(TM) 64-Bit Server VM (build 14.3-b01-101, mixed mode) -- You 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
lazy sequence question
I'm working my way through Programming Clojure and got an unexpected result with sequences: user (take 10 (filter even? (iterate inc 1))) (2 4 6 8 10 12 14 16 18 20) user (take-while #( % 10) (iterate inc 1)) (1 2 3 4 5 6 7 8 9) user (take 10 (filter #( % 10) (iterate inc 1))) ; Evaluation aborted. The first two work but the third one hangs. Why? Thanks, Mike -- You 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: lazy sequence question
On Dec 9, 10:35 pm, Mike K mbk.li...@gmail.com wrote: The first two work but the third one hangs. Why? user (take 5 (filter #( % 10) (iterate inc 1))) (1 2 3 4 5) OK, I figured out that it won't hang with taking = 9 elements, which is the total that pass the filter. But shouldn't it give me 9 items without hanging when I ask for 10 or more as in the first case? Mike -- You 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: lazy sequence question
There are only 9 items that satisfy your predicate. (take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream forever, endlessly searching for that 10th item it will never find. On Wed, Dec 9, 2009 at 9:41 PM, Mike K mbk.li...@gmail.com wrote: On Dec 9, 10:35 pm, Mike K mbk.li...@gmail.com wrote: The first two work but the third one hangs. Why? user (take 5 (filter #( % 10) (iterate inc 1))) (1 2 3 4 5) OK, I figured out that it won't hang with taking = 9 elements, which is the total that pass the filter. But shouldn't it give me 9 items without hanging when I ask for 10 or more as in the first case? Mike -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en
Re: lazy sequence question
But shouldn't it give me 9 items without hanging when I ask for 10 or more as in the first case? No. take returns a lazy sequence. The printer is trying to realize it in order to print it. It can't be completely realized until it's taken ten elements (at which point it's done, by definition). In realizing the sequence, the first nine items are collected. take wants one more. It tries to fetch it from the filtered lazy-seq. The filtered seq gets 10 from the iterate lazy-seq, which doesn't pass the filter. It gets 11, which doesn't pass the filter... Neither filter nor take know to abandon their attempt. That's how this works. Imagine if you wrote: user= (take 10 (filter #(or (= 1000 %) ( % 10)) (iterate inc 1))) (1 2 3 4 5 6 7 8 9 1000) It just keeps on going until it's found ten elements. -- You 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: lazy sequence question
Neither filter nor take know to abandon their attempt. That's how this works. Ah, of course. Thanks Mark and Richard! Mike -- You 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: lazy sequence question
On Dec 9, 9:46 pm, Mark Engelberg mark.engelb...@gmail.com wrote: There are only 9 items that satisfy your predicate. (take 10 ...) demands a 10th, and it keeps searching the (iterate inc 1) stream forever, endlessly searching for that 10th item it will never find. Aww. You make it sound so sad. -- You 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