please explain where and why to use var-quote

2010-08-04 Thread limux
i very confused var-quote, hope someone explain it more detailed than the clojure.org's, thks. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated

Re: please explain where and why to use var-quote

2010-08-04 Thread Meikel Brandmeyer
Hi, On Aug 4, 9:32 am, limux liumengji...@gmail.com wrote: i very confused var-quote, hope someone explain it more detailed than the clojure.org's, thks. Global values are stored in so-called Vars. Symbols are used in program code to link to those Vars, ie. to basically give them a name. So

Re: Keywords also have a literal syntax

2010-08-04 Thread Michał Marczyk
On 4 August 2010 07:33, vishy vishalsod...@gmail.com wrote: What does it mean? It simply means that there is a class of strings which will be read in by the reader as keywords. (This is the class of strings starting with one or two colons followed by a string of characters which would, on its

Re: What is #_

2010-08-04 Thread Ted Naleid
I've seen situations where #_ still affects the code (or at least allows it to compile). reduce expects a function with 2 parameters, one for If you try to use the #() macro, but only use the first implicit parameter (%1), it'll blow up with an IllegalArgumentException: user= (reduce #(+ %1 1)

Re: What is #_

2010-08-04 Thread Yang Dong
Thank you, that really helps! On Aug 4, 1:38 pm, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 4, 2:32 am, Yang Dong ydong.pub...@gmail.com wrote: Thank you! I have just another question not related about this topic: ;during bootstrap we don't have destructuring let, loop or fn, will

Generics in PersistentXXX classes

2010-08-04 Thread Alex Tkachman
Hi! Are there any plans to generify Clojure's collections like PersistentHashMap etc. to make them usable for Java/Scala/Groovy++ people? Does it make sense at all? If the only issue is resources I am volunteering to help. Best regards Alex -- You received this message because you are

Re: What is #_

2010-08-04 Thread Meikel Brandmeyer
Hi, On Aug 4, 7:43 am, Ted Naleid cont...@naleid.com wrote: There might be other situations though where #_ and the thing it comments can still have an impact on how the code executes, just something I ran across recently that slightly adjusted my thinking on #_. Well... You always have to

Re: Generics in PersistentXXX classes

2010-08-04 Thread Meikel Brandmeyer
Hi, On Aug 4, 12:10 pm, Alex Tkachman alex.tkach...@gmail.com wrote: Are there any plans to generify Clojure's collections like PersistentHashMap etc. to make them usable for Java/Scala/Groovy++ people? Does it make sense at all? If the only issue is resources I am volunteering to help.

starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
Apologies for the length of this message -- I'm hoping to be complete, but that made the message pretty long. Also BTW most of the tests below were run using Clojure 1.1. If part of the answer to my questions is use 1.2 then I'll upgrade ASAP (but I haven't done so yet because I'd prefer to

Re: Generics in PersistentXXX classes

2010-08-04 Thread Matt Fowles
Alex~ There is a project on github that does exactly this. http://github.com/krukow/clj-ds I don't know much about the current state of it, but I have plans in the next month or so to try it out at work. http://github.com/krukow/clj-dsMatt On Wed, Aug 4, 2010 at 6:10 AM, Alex Tkachman

Re: Resource cleanup when lazy sequences are finalized

2010-08-04 Thread Cameron
Not 100% on this, but this is what I do when reading files... (with-open [rdr (BufferedReader. (FileReader. file-name))] (reduce conj [] (line-seq rdr))) That ensures that the whole seq is realized without closing the handle, but it also allows you to wrap the whole block with a take

Re: Resource cleanup when lazy sequences are finalized

2010-08-04 Thread Meikel Brandmeyer
Hi, On Aug 4, 4:56 pm, Cameron cpuls...@gmail.com wrote: Not 100% on this, but this is what I do when reading files... (with-open [rdr (BufferedReader. (FileReader. file-name))]     (reduce conj [] (line-seq rdr))) An easier way to do this is doall. That ensures that the whole seq is

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread David Nolen
Have you considered that you're realizing very large lazy sequences and might be thrashing around in GC ? The parallel versions needs X times the available memory of the sequential version, where X is the number of concurrent threads right? David On Wed, Aug 4, 2010 at 10:36 AM, Lee Spector

Re: please explain where and why to use var-quote

2010-08-04 Thread limux
Thanks for your very very helpful help. Another question is: defmacro defmodel [model-name] `(let [sym-model-name ~(symbol (str app.model. model-name))] (do On 8月4日, 下午3时42分, Meikel Brandmeyer m...@kotka.de wrote: Hi, On Aug 4, 9:32 am, limux liumengji...@gmail.com wrote: i very

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 11:36 AM, David Nolen wrote: Have you considered that you're realizing very large lazy sequences and might be thrashing around in GC ? The parallel versions needs X times the available memory of the sequential version, where X is the number of concurrent threads right?

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Laurent PETIT
2010/8/4 David Nolen dnolen.li...@gmail.com Have you considered that you're realizing very large lazy sequences and might be thrashing around in GC ? The parallel versions needs X times the available memory of the sequential version, where X is the number of concurrent threads right? David,

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Laurent PETIT
2010/8/4 Laurent PETIT laurent.pe...@gmail.com 2010/8/4 David Nolen dnolen.li...@gmail.com Have you considered that you're realizing very large lazy sequences and might be thrashing around in GC ? The parallel versions needs X times the available memory of the sequential version, where X is

Re: please explain where and why to use var-quote

2010-08-04 Thread limux
Thanks for your very very helpful help. I want to do something like rails's activerecord orm, The following is the primary idea: (defmacro defmodel [model-name] `(let [temp# ~(symbol (str app.model. model-name))] (do ;; create the namespace according to model name

Re: please explain where and why to use var-quote

2010-08-04 Thread Nicolas Oury
2010/8/4 limux liumengji...@gmail.com: Thanks for your very very helpful help.  I want to do something like rails's activerecord orm, The following is the primary idea: (defmacro defmodel [model-name]   `(let [temp# ~(symbol (str app.model. model-name))]       (do           ;; create the

Re: let binding and recursive function

2010-08-04 Thread Emeka
Hello John, I would want to add something to what Justin said. (defn goo [ i k l] (println l)) = (goo 2 3 [233]) ;;; gives ([233]) (conj '([233]) ...) (defn goo [i k [l]](println l)) =(goo 2 3 [233]) ;;; gives [233] (conj [233] ...) Hope the difference is clear now. Emeka On Mon, Aug 2,

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread David Nolen
On Wed, Aug 4, 2010 at 12:05 PM, Lee Spector lspec...@hampshire.edu wrote: Thanks! I hadn't really thought about that. I realized there'd be a lot of gc -- part of what makes my burn reliably slow is all of the allocation -- but I didn't consider how that would affect the concurrency. I don't

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 12:12 PM, Laurent PETIT wrote: Lee, I don't have the general answer, but as a related note, I think there may be a problem with the with futures version: a. you quickly bootstrap all futures in the inner call to map b. you collect the results of the futures in parallel

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 12:38 PM, David Nolen wrote: Why not just replace burn with a large number of arithmetic operations? Memory issues have a less chance of coming into play then. Primitive arithmetic operations. Like (+ (int a) (int b)) In some of my previous attempts to do that the

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 12:35 PM, David Nolen wrote: 8gb of ram seems kinda low to me for this kind of microbenchmark, especially when running 16 or 48 cores. But I'm no expert. As a far-fetched comparison when I played around with Aleph on 8-core box, doing nothing but hitting the server as

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Mark Engelberg
I agree that the burn-with-futures code looks not right: (defn burn-via-futures [n] (print n burns via futures: ) (time (doall (pmap deref (map (fn [_] (future (burn))) (range n)) should probably be something like: (defn burn-via-futures

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread David Nolen
On Wed, Aug 4, 2010 at 1:35 PM, Lee Spector lspec...@hampshire.edu wrote: I'm still interested in any feedback on my is there a best way -- idiomatically and with respect to performance... question, and I would still like to better understand where those anomalies came from and how to avoid

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Armando Blancas
What about a more direct way of creating your threads. This code is too simple and more is needed to collect results with futures, but I wonder how something like this would perform on your machine: (defn burn-via-pool [n] (print n burns via a thread pool: ) (time (let [cores (.. Runtime

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
In Clojure 1.1.0 (which is what I have running on the big machines) I get a warning and then an error from your ^Callable line: WARNING: reader macro ^ is deprecated; use meta instead Exception in thread main java.lang.IllegalArgumentException: let requires an even number of forms in binding

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
Thanks Mark, This makes sense and I've substituted your version, although I don't think it was really making a difference in this case since creating futures should be fast (and that seems to be what the data was showing too). -Lee On Aug 4, 2010, at 1:41 PM, Mark Engelberg wrote: I

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Meikel Brandmeyer
Hi, Am 04.08.2010 um 20:24 schrieb Lee Spector: In Clojure 1.1.0 (which is what I have running on the big machines) I get a warning and then an error from your ^Callable line: WARNING: reader macro ^ is deprecated; use meta instead Exception in thread main

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Armando Blancas
Sorry, you had mentioned 1.1. The hint should be #^Callable On Aug 4, 11:24 am, Lee Spector lspec...@hampshire.edu wrote: In Clojure 1.1.0 (which is what I have running on the big machines) I get a warning and then an error from your ^Callable line: WARNING: reader macro ^ is deprecated;

Re: Generics in PersistentXXX classes

2010-08-04 Thread Alex Tkachman
Guys, Thanks fo reference. I am still be curious if it should be done directly in Clojure runtime and available if clojure.jar is in classpath Alex On Wed, Aug 4, 2010 at 4:51 PM, Matt Fowles matt.fow...@gmail.com wrote: Alex~ There is a project on github that does exactly this.

Re: bugs in with-local-vars and lexically-nested-function access to outer function parameters

2010-08-04 Thread Dale
This statement is ironic, considering the definition of a functional closure, after which Clojure is presumably named. You're missing the point. A defn inside another defn doesn't do what you think it does. defn always creates a global variable, even when it looks like it should create a

Re: Resource cleanup when lazy sequences are finalized

2010-08-04 Thread Jeff Palmucci
Right, that'll work, but it is no longer lazy in the sense that it will read the whole sequence into memory (a problem for me because my sequences are 10s of GB long, compressed). The feature I was trying to show is that the yield function allows you to make *arbitrary* non-lazy code lazy. (not

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
I'm hoping there's at least a bronze bullet :-). Thanks for the pointer to VisualVM -- I'm relatively new to the Java world and haven't yet used such things. -Lee On Aug 4, 2010, at 1:59 PM, David Nolen wrote: I don't think there's a silver bullet as illustrated by the performance

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 2:37 PM, Armando Blancas wrote: Sorry, you had mentioned 1.1. The hint should be #^Callable Making this change, along with Mark's suggested change to burn-via-futures (except that I had to change the inner dorun to doall), I get the results below. It doesn't look to me

Re: Symbol substitution in macro

2010-08-04 Thread Andrew Boekhoff
Hi, because the symbol's namespace is then nil, and you still can't tell if they're shadowing it with a let binding, or have renamed it with :as. If the namespace is nil then its either been :used or :required. You could check ns-refers to see if its been :used. If its been shadowed the

Re: defrecord and map equality?

2010-08-04 Thread Rich Hickey
On Jul 29, 11:51 pm, Ryan Twitchell metatheo...@gmail.com wrote: Hi all, I noticed (with a very recent git pull) the following asymmetric behavior regarding = and records: (defrecord my-record [a]) (def r (new my-record 1)) (def s (new my-record 1)) (= r s)        ;; true (= s r)    

Re: Symbol substitution in macro

2010-08-04 Thread Kyle Schaffrick
On Wed, 4 Aug 2010 14:58:46 -0400 Andrew Boekhoff boekho...@gmail.com wrote: Hi, because the symbol's namespace is then nil, and you still can't tell if they're shadowing it with a let binding, or have renamed it with :as. If the namespace is nil then its either been :used or

Re: java.lang.OutOfMemoryError

2010-08-04 Thread atucker
Thanks! This is still driving me mad 'though. On Jul 27, 5:11 pm, Peter Schuller peter.schul...@infidyne.com wrote: The observations that the data structures are non-lazy still apply, even if you could postpone the problem by increasing the heap size. Yes I can see that the sequence returned

Re: java.lang.OutOfMemoryError

2010-08-04 Thread atucker
Cheers. But tests suggest to me that (for...) has the same laziness characteristics --or lack thereof-- as does (map...) On Jul 26, 6:56 pm, Randy Hudson randy_hud...@mac.com wrote: You can get a lazy sequence of all the lines in all the files by something like: (for [file out-files      

Re: Running on .Net

2010-08-04 Thread eyeris
I tried to build the latest ClojureCLR using VS 2008. I used the DLR 1.0 release. I successfully replaced your DLR project references and built them: http://imgur.com/SgUmu.jpg Then I added a DLR reference to the Clojure project and built it, resulting in these two errors The extern alias MSC

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Matt Fowles
Lee~ Doug Lea (of java.util.Concurrent fame) designed a framework called Fork/Join which is made to separate the idea of work from threads so that things can be parallelized out as much as possible. I don't know clojure that well, but would guess that it has some support for it and that you

Need help with syntax for implementing multiple arity protocol method

2010-08-04 Thread James
I am having trouble getting syntax right when defining a protocol function/method with multiple arities. When the defrecord is evaluated I get: java.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol [Thrown class java.lang.RuntimeException] I have

Speeding up equals using the cached hash code?

2010-08-04 Thread sune.simonsen
I was looking around the Clojure source code and noticed that the persistent immutable collections caches their hash codes. The java doc says the following about the equals method: (http:// download.oracle.com/javase/1.4.2/docs/api/java/lang/Object.html) If two objects are equal according to the

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Lee Spector
On Aug 4, 2010, at 3:00 PM, Matt Fowles wrote: Doug Lea (of java.util.Concurrent fame) designed a framework called Fork/Join which is made to separate the idea of work from threads so that things can be parallelized out as much as possible. I don't know clojure that well, but would

Re: starting and getting the most out of concurrent processes

2010-08-04 Thread Armando Blancas
I doubt whether any framework will optimize performance without some sort of configuration. This fork/join example requires a threshold for resorting to sequential processing and the number of threads allowed at any one time: MaxWithFJ mfj = new MaxWithFJ(problem, threshold);

Re: Need help with syntax for implementing multiple arity protocol method

2010-08-04 Thread Randy Hudson
You need to name the protocol before the method implementations. That's why the PersistentList cannot be cast to Symbol message -- the compiler's expecting a protocol (or interface) symbol after [r]. And, as the examples on http://clojure.org/protocols show, you need to define the different

Re: Running on .Net

2010-08-04 Thread Hadi Hariri
If you're building inside the IDE, go to the Clojure.project and locate the Microsoft.Scripting.Core assembly in References. Click Properties and in the Aliases, set it to global,MSC (without the quotes). It should be default global On 4 August 2010 20:59, eyeris drewpvo...@gmail.com wrote: I

Re: Running on .Net

2010-08-04 Thread dmiller
the 7/23 date is, as they say, not operational. I've edited that out. I'll go as far as 'soon'. (The new PC I was going supposed to move to and install VS2010 on has to be replaced due to the possibility that the hard disk will fry.) You cannot use DLR 1.0. I need things that are not in that

processing sequence/collection of functions

2010-08-04 Thread foop1
Hi, Does anyone of you can say as to how to pass in a collection/sequence of functions as input? for ex pass in a vector /sequence [ function1 function2 function3] at the other end it would read in the vector and execute those functions Thank you -- You received this message because you are

Re: processing sequence/collection of functions

2010-08-04 Thread Miki
Hello, Does anyone of you can say as to how to pass in a collection/sequence of functions as input? for ex pass in a vector /sequence [ function1 function2 function3] at the other end it would read in the vector and execute those functions user= (defn f1 [] 1) #'user/f1 user= (defn f2[] 2)

Re: processing sequence/collection of functions

2010-08-04 Thread foop1
Hmm interesting , Thank you for your answer. On Aug 5, 12:36 am, Miki miki.teb...@gmail.com wrote: Hello, Does anyone of you can say as to how to pass in a collection/sequence of functions as input? for ex pass in a vector /sequence [ function1 function2 function3] at the other end it