Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan 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 an object after a new

Re: Performance of seq on empty collections

2010-11-17 Thread Laurent PETIT
2010/11/16 Meikel Brandmeyer > Salut Laurent, > > On 16 Nov., 09:51, Laurent PETIT 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 paper waste. As I > said: qui

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

2010-11-17 Thread Alex Osborne
Alyssa Kwan 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 don't know if it's inten

Re: Performance of seq on empty collections

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 09:44, Laurent PETIT 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 W)) >  

Re: fastest way to remove nils

2010-11-17 Thread Steve Purcell
Miki 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 constru

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 wrote: > On Wednesday, November 17, 2010, Sunil S Nandihalli > wrote: > > Regarding your bimap implementation, in terms of complexity, I feel, it > will be lin

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 t

Re: Ghost Vars?

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 13:39, Alyssa Kwan 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 function is called is pr

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 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 doc > string so

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 # user> (.toString d) "hello" user> (.toGMTString d) "17 Nov 2010 12:57:28 GMT" user> (update-proxy d {"toGM

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 wrote: > 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 (prox

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 Great, thank you. On Wed, Nov 17, 2010 at 8:31 AM, atreyu wrote: > Hi, i added your example (quoting the source) to >

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 > 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

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 > > > 2010/11/17 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

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 wrote: > In 1.2, functions were always looked up through their vars. While this is a > low-cost operation, it does n

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 i

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

2010-11-17 Thread Meikel Brandmeyer
Hi, On 17 Nov., 16:29, David Sletten 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

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 ac

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 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 confusion. > > Stu > > >

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 integer

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 wrote: > Hi all, > > I'm doing a bit of

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

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Alyssa Kwan 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 compile/clinit time. Oh, I see

Re: Enclojure for Clojure 1.2

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 3:54 PM, Harrison Maseko 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 post to this

Re: fastest way to remove nils

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 7:55 PM, Robert McIntyre 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 (remo

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 db.clj

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 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 having to load the l

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? 1

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 iteratio

Re: Closures eat permgen?

2010-11-17 Thread Matt Fowles
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 -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled Matt PS - http://blogs.sun.com/

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 exceptions.

Re: Ghost Vars?

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 9:57 PM, Alyssa Kwan 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 the > JVM, and dese

Re: Closures eat permgen?

2010-11-17 Thread Ken Wesson
On Wed, Nov 17, 2010 at 10:12 PM, Matt Fowles 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 > -XX:+UseConcMarkSweep

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 - wrote: > On Wed, Nov 17, 2010 at 9:51 PM, Ken Wesson 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 at a stage when the exact fun

Re: Calling function in required library in a different namespace

2010-11-17 Thread Adrian Cuthbertson
> 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, e.g; xxlib.clj... (ns xxlib) (defn xxfoo [] :xxfoo) db.clj... (ns db (:require

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 f

Re: Ghost Vars?

2010-11-17 Thread Alex Osborne
Hi Alyssa, Alyssa Kwan 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 like this? (def

Re: Calling function in required library in a different namespace

2010-11-17 Thread Meikel Brandmeyer
Hi, On 18 Nov., 04:48, Adrian Cuthbertson 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, e.g; > > xxlib.c

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

2010-11-17 Thread Meikel Brandmeyer
Salut Laurent, On 17 Nov., 16:53, Laurent PETIT 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 function itself is made a