Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan alyssa.c.k...@gmail.com writes: ns-unmap isn't typically used. But for durability, we can think of JVM shutdown/startup as unmapping everything and starting fresh. Therefore, expected behavior for ns-unmap should be the same as behavior for deserializing and loading

Re: Performance of seq on empty collections

2010-11-17 Thread Laurent PETIT
2010/11/16 Meikel Brandmeyer m...@kotka.de Salut Laurent, On 16 Nov., 09:51, Laurent PETIT laurent.pe...@gmail.com wrote: Agreed with the explanation, but ... 12% of what, exactly ? 6,502692ms / 7,393586ms ~ 0,88 = 12% improvement, no? But maybe this whole microbenchmarking story is

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Alex Osborne
Alyssa Kwan alyssa.c.k...@gmail.com writes: In any case, I am using Github master and I thought I was using 1.2. 1.2 has self-references lexically bound, as David Sletten points out, which I agree is the correct behavior. But something has happened on 1.3 alpha that has changed that. I

Re: Performance of seq on empty collections

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 09:44, Laurent PETIT laurent.pe...@gmail.com wrote: I don't know. But my thougts were just that if you want to measure the time for a particular way W of coding things (and a variant Wv), and you test this with other computations OC, then (not=   (/ (time Wv)      (time

Re: fastest way to remove nils

2010-11-17 Thread Steve Purcell
Miki miki.teb...@gmail.com writes: user= (time (remove nil? (repeat 100 nil))) Elapsed time: 0.079312 msecs () user= (time (filter identity (repeat 100 nil))) Elapsed time: 0.070249 msecs () Seems like filter is a bit faster, however YMMV You're not timing the execution, just the

Re: bimaps in clojure

2010-11-17 Thread Sunil S Nandihalli
Hi Christophe Grand Yea true I kind of got confused .. thanks for the solution.. Sunil On Wed, Nov 17, 2010 at 1:12 PM, Christophe Grand christo...@cgrand.netwrote: On Wednesday, November 17, 2010, Sunil S Nandihalli sunil.nandiha...@gmail.com wrote: Regarding your bimap implementation, in

Re: Ghost Vars?

2010-11-17 Thread Alyssa Kwan
Hi Alex, I understand exactly why this situation exists. I just think the behavior is unexpected. When I create a function with a dynamic binding, I expect the function to keep a reference to the *name*, not the var that the name resolves to at compile/clinit time. Using with- bindings* seems

Re: Ghost Vars?

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 13:39, Alyssa Kwan alyssa.c.k...@gmail.com wrote: Using with-bindings* seems terribly unsupported as well. with-bindings* is official API and the above is a valid use. I would expect that the current situation is there for performance reasons. Resolving the Var each time the

Re: Add method implementations to proxy

2010-11-17 Thread Mark Rathwell
Beautiful. Thank you! On Wed, Nov 17, 2010 at 2:07 AM, Liam liam.ga...@gmail.com wrote: More information from Rich himself about update-proxy when he first introduced it. Could not find examples for you except from the Joy of Clojure book on page 273, but it is very trivial... just like the

Re: Add method implementations to proxy

2010-11-17 Thread Mark Rathwell
An example of update-proxy in case it may help anyone in the future: user (import java.util.Date) java.util.Date user (def d (proxy [Date] [] (toString [] hello))) #'user/d user d #Date$0 hello user (.toString d) hello user (.toGMTString d) 17 Nov 2010 12:57:28 GMT user (update-proxy d

Re: Add method implementations to proxy

2010-11-17 Thread atreyu
Hi, i added your example (quoting the source) to http://clojuredocs.org/clojure_core/clojure.core/update-proxy On Nov 17, 2:05 pm, Mark Rathwell mark.rathw...@gmail.com wrote: An example of update-proxy in case it may help anyone in the future: user (import java.util.Date) java.util.Date

Re: Add method implementations to proxy

2010-11-17 Thread Mark Rathwell
Hi, i added your example (quoting the source) to http://clojuredocs.org/clojure_core/clojure.core/update-proxy http://clojuredocs.org/clojure_core/clojure.core/update-proxyGreat, thank you. On Wed, Nov 17, 2010 at 8:31 AM, atreyu atreyu@gmail.com wrote: Hi, i added your example (quoting

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Stuart Halloway
In 1.2, functions were always looked up through their vars. While this is a low-cost operation, it does not allow maximum performance. In 1.3, function calls are compiled through their vars. If function a calls function c inside its body, there is no runtime lookup of the var c. However, each

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Laurent PETIT
2010/11/17 Stuart Halloway stuart.hallo...@gmail.com In 1.2, functions were always looked up through their vars. While this is a low-cost operation, it does not allow maximum performance. In 1.3, function calls are compiled through their vars. If function a calls function c inside its body,

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread nicolas.o...@gmail.com
In 1.3, function calls are compiled through their vars. If function a calls function c inside its body, there is no runtime lookup of the var c. However, each function makes a (very low cost) check on entry to see if anything has been recompiled. If so, the function is recompiled. This

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Laurent PETIT
2010/11/17 Laurent PETIT laurent.pe...@gmail.com 2010/11/17 Stuart Halloway stuart.hallo...@gmail.com In 1.2, functions were always looked up through their vars. While this is a low-cost operation, it does not allow maximum performance. In 1.3, function calls are compiled through their

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Alyssa Kwan
The issue here is not with b pointing to a. It's that b should point to b but doesn't. This *can't* be seen to be correct. Thanks, Alyssa Kwan On Nov 17, 9:22 am, Stuart Halloway stuart.hallo...@gmail.com wrote: In 1.2, functions were always looked up through their vars. While this is a

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread David Sletten
On Nov 17, 2010, at 9:22 AM, Stuart Halloway wrote: In 1.2, functions were always looked up through their vars. While this is a low-cost operation, it does not allow maximum performance. In 1.3, function calls are compiled through their vars. If function a calls function c inside its

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 16:29, David Sletten da...@bosatsu.net wrote: = (defn a    ([x] x)    ([x y] (+ (a x) (a y #'user/a = (a 1 2) 3 = (def b a) #'user/b = (b 1 2) 3 = (defn a [x]    (- x)) #'user/a = (b 1 2) -3 Let's call the original function assigned to 'a' a0

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Laurent PETIT
Meikel, while a good description of how things work in 1.2, it's not accurate for 1.3, and my point was that Stu's description of how 1.3 works (by using words like the function is recompiled) does not match with my own knowledge of what had been done in 1.3 the days just before the conj. Since

Re: Ghost Vars?

2010-11-17 Thread Tim Daly
In a common lisp setting a symbol could be represented as vector containing slots. Two of the slots are of interest, the function slot and the value slot. The symbol looks like: -- | function | value | package | alist |

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Stuart Halloway
I am wrong, there was a bug here, and Rich just fixed it. https://github.com/clojure/clojure/commit/8225407032ea643cbe3db7f35ef97b1230fc65b8 Please retry against master, and sorry for inflicting more confusion. Stu Meikel, while a good description of how things work in 1.2, it's not

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Alyssa Kwan
Thanks everyone! Alyssa Kwan On Nov 17, 11:10 am, Stuart Halloway stuart.hallo...@gmail.com wrote: I am wrong, there was a bug here, and Rich just fixed it. https://github.com/clojure/clojure/commit/8225407032ea643cbe3db7f35ef... Please retry against master, and sorry for inflicting more

Converting from 1.2 to 1.3-alpha3

2010-11-17 Thread nicolas.o...@gmail.com
Dear all, I am trying top port some code from 1.2 to 1.3 and I end up with this error: Unknown location: error: java.lang.VerifyError: (class: nicolasoury/distributions/core/HashNodeDistribution, method: delete_BANG_ signature: (Ljava/lang/Object;I)Ljava/lang/Object;) Expecting to find

Enclojure for Clojure 1.2

2010-11-17 Thread Harrison Maseko
Does Enclojure support Clojure 1.2 yet? Thanks, -h. -- 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.

Re: REQUEST for feedback on http://clojure.org

2010-11-17 Thread Allen Johnson
I think annotations support was added in 1.2. Could we add some information to the Java Interop section regarding this? https://groups.google.com/group/clojure/browse_thread/thread/d2128e1505c0c117?pli=1 Allen On Sat, Oct 30, 2010 at 10:38 PM, Alex Miller alexdmil...@yahoo.com wrote: Hi all,

Re: fastest way to remove nils

2010-11-17 Thread Robert McIntyre
So, just to be clear, user (def nil-seq (doall (interleave (repeat 1e5 nil) (repeat 1e5 whatever))) ) #'user/nil-seq user (time (doall (keep identity nil-seq))) Elapsed time: 122.485848 msecs user (time (doall (remove nil? nil-seq))) Elapsed time: 149.71484 msecs --Robert McIntyre On Wed,

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Alyssa Kwan alyssa.c.k...@gmail.com writes: I understand exactly why this situation exists. I just think the behavior is unexpected. When I create a function with a dynamic binding, I expect the function to keep a reference to the *name*, not the var that the name resolves to at

Re: Enclojure for Clojure 1.2

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 3:54 PM, Harrison Maseko lis...@gmail.com wrote: Does Enclojure support Clojure 1.2 yet? Yes. I've been using Clojure 1.2/Enclojure 1.4/NB 6.9.1 for the past few weeks myself. -- You received this message because you are subscribed to the Google Groups Clojure group. To

Re: fastest way to remove nils

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 7:55 PM, Robert McIntyre r...@mit.edu wrote: So, just to be clear, user (def nil-seq (doall (interleave (repeat 1e5 nil) (repeat 1e5 whatever))) ) #'user/nil-seq user (time (doall (keep identity nil-seq))) Elapsed time: 122.485848 msecs user (time (doall (remove

Calling function in required library in a different namespace

2010-11-17 Thread Victor Olteanu
Hi, Please excuse my newbie ignorance - I would like to do something that seems pretty basic, yet I couldn't figure it out yet. I would like to call a function that is loaded in a different namespace, but without having to load the library again in the current namespace - more precisely: in

Re: Calling function in required library in a different namespace

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 9:36 PM, Victor Olteanu bluestar...@gmail.com wrote: Hi, Please excuse my newbie ignorance - I would like to do something that seems pretty basic, yet I couldn't figure it out yet. I would like to call a function that is loaded in a different namespace, but without

Re: Ghost Vars?

2010-11-17 Thread Alyssa Kwan
Hi Alex, OK, I agree. Dynamic vars are not the same as traditional dynamic scoping. For what I'm doing (making functions durable), it raises the question: If you persist a function that points to a var, restart the JVM, and deserialize/load the function from a data store, what should happen?

Re: Closures eat permgen?

2010-11-17 Thread Ken Wesson
I ran some tests: (defn domany [n s] (reduce (fn [a b] (assoc a :foo (.getClass b))) {} (take n s))) (def fnseq (iterate (fn [_] (fn [x] (+ 2 x))) 0)) (domany 1000 fnseq) With these, the last operation grinds away for a long time (a lot more than 10x what it takes with only 100

Re: Calling function in required library in a different namespace

2010-11-17 Thread Victor -
I used to do that before, but I realized I was introducing a level of indirection at a stage when the exact function signatures weren't clear yet. I do agree that the preferred final solution can well be to always call through function in the other namespace, though I think there may be

Re: Ghost Vars?

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 9:57 PM, Alyssa Kwan alyssa.c.k...@gmail.com wrote: Hi Alex, OK, I agree.  Dynamic vars are not the same as traditional dynamic scoping. For what I'm doing (making functions durable), it raises the question:  If you persist a function that points to a var, restart

Re: Closures eat permgen?

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 10:12 PM, Matt Fowles matt.fow...@gmail.com wrote: Ken~ Not sure what jvm args you are running with, but not all GC settings will sweep or clear the permgen.  You should try it with: -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+UseParNewGC

Re: Calling function in required library in a different namespace

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 10:26 PM, Victor - bluestar...@gmail.com wrote: On Wed, Nov 17, 2010 at 9:51 PM, Ken Wesson kwess...@gmail.com wrote: Why not just have, in db.clj. (def somefunction mylib/somefunction) I used to do that before, but I realized I was introducing a level of indirection

Re: Closures eat permgen?

2010-11-17 Thread Matt Fowles
Ken~ CMS (Concurrent Mark Sweep) is part of a multi-stage generational GC. It is the newest GC in a released version of the JVM (the G1 GC not having been released yet). With the below settings, the young gen is divided into Eden and two survivor spaces. The survivor spaces act as generations

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan alyssa.c.k...@gmail.com writes: For what I'm doing (making functions durable), it raises the question: If you persist a function that points to a var, restart the JVM, and deserialize/load the function from a data store, what should happen? So you're doing something

Re: Calling function in required library in a different namespace

2010-11-17 Thread Meikel Brandmeyer
Hi, On 18 Nov., 04:48, Adrian Cuthbertson adrian.cuthbert...@gmail.com wrote: in db.clj I have  (:require [some-library :as mylib]) in api.clj: I have (:require [myapp.db :as db]) I then want to call mylib/somefunction - You can use some-library/... directly after requiring db,

Re: Dynamic Binding of Self-Referencing Functions Expected Behavior?

2010-11-17 Thread Meikel Brandmeyer
Salut Laurent, On 17 Nov., 16:53, Laurent PETIT laurent.pe...@gmail.com wrote: while a good description of how things work in 1.2 It doesn't even do that. This is exactly *not* the way it works in 1.2, because self-references don't go through the Var. I'd be curious to know, why calling the