Loading clojure code during runtime

2011-03-11 Thread finbeu
Hello, I'm still fairly new to Clojure but what I can say so far is that it is awesome :-) I'm currently implementing a cache as an atom that gets updates from an external application. I expose the cache items to clients via a webservice using compojure. Actually I return a list for each request.

Re: Why does this break memoization?

2011-03-11 Thread Tassilo Horn
Ken Wesson writes: Hi Ken & Alan, > Adding metadata to an object produces a new object, rather than > altering the existing object. Every time you increment the counter > for a function in p it becomes different, and the memoize treats it as > new. Then I've misread that statement on the homep

Re: Loading clojure code during runtime

2011-03-11 Thread Benny Tsai
(read-string) converts a string into a Clojure object, which can then be (eval)ed: (let [f (eval (read-string "(fn [x] (* x 2))"))] (map f [1 2 3])) user=> (2 4 6) So you could do something like: (let [f (eval (read-string (slurp "function.txt")))] (map f [1 2 3])) -- You received this m

Re: Loading clojure code during runtime

2011-03-11 Thread finbeu
beautiful! Thx. On 11 Mrz., 10:23, Benny Tsai wrote: > (read-string) converts a string into a Clojure object, which can then be > (eval)ed: -- 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

DOM API for Clojure

2011-03-11 Thread K.
Hello, Is there a library to manipulate (create and modify) a XML DOM tree in Clojure? If possible with the "classic" syntax (XML tags represented as Clojure vectors.) I need to keep an instance of a DOM tree in my program and modify it and recreating the whole DOM tree every time would not be ef

Re: Why does this break memoization?

2011-03-11 Thread Ken Wesson
On Fri, Mar 11, 2011 at 3:54 AM, Tassilo Horn wrote: > Ken Wesson writes: > > Hi Ken & Alan, > >> Adding metadata to an object produces a new object, rather than >> altering the existing object.  Every time you increment the counter >> for a function in p it becomes different, and the memoize tre

Re: overriding keyword behavior?

2011-03-11 Thread Stuart Sierra
It is not possible to turn an interface into a protocol. When protocols first appeared, the idea was floated to replace the low-level interfaces like ILookup with equivalent protocols, but this idea has not received substantial attention since. -Stuart Sierra clojure.com -- You received this

Re: clojure.string/replace-first return nil when not matched

2011-03-11 Thread Stuart Sierra
> > (require '[clojure.string :as str]) > (str/replace-first "abc def" #"ghi" (fn [a] (str a a))) > => nil > That's a bug. Created http://dev.clojure.org/jira/browse/CLJ-753 Thanks for the report. -Stuart Sierra clojure.com -- You received this

Re: DOM API for Clojure

2011-03-11 Thread Stuart Sierra
It's not the DOM API, but take a look at Zippers as an efficient way to manipulate tree-like structures, including XML. Luke VanderHart's Clojure Conj talk on Zippers is here: http://clojure.blip.tv/file/4503162/ -Stuart Sierra clojure.com -- You received this message because you are subscrib

Re: Comparing clojure speed to java speed

2011-03-11 Thread Chouser
On Thu, Mar 10, 2011 at 11:26 PM, Jarl Haggerty wrote: > Hmm, I should have thought of that. > > New Clojure: > > (ns hello.test >  (import org.jbox2d.common.Vec2) >  (:gen-class)) > > (defn -main [& args] >  (dotimes [q 5] >    (let [#^Vec2 a (Vec2. 1 2) >          #^Vec2 b (Vec2. 3 4)] >      (t

Re: DOM API for Clojure

2011-03-11 Thread K.
> It's not the DOM API, but take a look at Zippers as an efficient way to > manipulate tree-like structures, including XML. I can see how it could be used to walk the tree but I don't see how it could be used to modify just a few branches / leafs in the tree. Calling zip/root reconstructs the whol

Re: DOM API for Clojure

2011-03-11 Thread Stuart Sierra
If you want to receive a DOM object from Java, manipulate it, and then return a DOM object back to Java, without rebuilding it, you're probably stuck manipulating it through the Java DOM APIs. -Stuart Sierra clojure.com -- You received this message because you are subscribed to the Google Grou

Re: DOM API for Clojure

2011-03-11 Thread K.
Could monads help me to build a pure functional Clojure interface for this while the underlying DOM manipulations would be not pure? -- 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 tha

Re: setup and propagation of config-params

2011-03-11 Thread faenvie
> (set-opt :development) ; this is what you want > ... > (get-opt :show-sql) ; need this flag hi armando, this is more of an OO style but as there is no def- , the state is still accessible from the outside. also the api is kinda asymetric. as described in 'the joy of clojure 7.2 - sharing closu

Re: overriding keyword behavior?

2011-03-11 Thread Joost
On Mar 10, 5:31 pm, kurtharriger wrote: > That was basically my question, protocols are designed for this but > ILookup isn't a protocol.  Is it possible to make ILookup into a > protocol?  I haven't looked at the java code much at all, but I might > take a stab at creating a patch it that seems p

clojure 1.3 testbuild1, enlive, and dependency ranges

2011-03-11 Thread Hugo Duncan
Hi, I have a project that depends on enlive, which uses a dependency range in its clojure dependency. This seems to cause all possible versions of clojure to be pulled down, including clojure-1.3.0-testbuild1-SNAPSHOT, which is broken (parent pom is in a release repo which isn't listed in

Re: clojure 1.3 testbuild1, enlive, and dependency ranges

2011-03-11 Thread Stuart Halloway
> Hi, > > I have a project that depends on enlive, which uses a dependency range in its > clojure dependency. This seems to cause all possible versions of clojure to > be pulled down, including clojure-1.3.0-testbuild1-SNAPSHOT, which is broken > (parent pom is in a release repo which isn't li

Re: Monad Lessons

2011-03-11 Thread Daniel Werner
On Mar 9, 8:15 pm, jim wrote: > So, my question is how many would be interested in such a session? > This would be a basic introduction to monads. Future session could be > about more advanced monad topics, if there was a demand for that. I'd *love* to attend. Even with such a vast amount of onli

Clojure 1.3 Alpha 6

2011-03-11 Thread Stuart Halloway
Clojure 1.3 Alpha 6 is now available at http://clojure.org/downloads 0 Changes from 1.3 Alpha 5 to 1.3 Alpha 6 1 Changes from 1.3 Alpha 4 to 1.3 Alpha 5 2 Changes from 1.3 Alpha 3 to 1.3 Alpha 4 3 Changes from 1.3 Alpha 2 to 1.3 Alpha 3 4 Changes from 1.3 Alpha 1 to 1.3 Alpha 2 5 Ch

Re: Clojure 1.3 alpha 1 report - bitwise operations extremely slow

2011-03-11 Thread Stuart Halloway
> That doesn't sound like the same bug discussed in this thread though. > We were talking about how operators like bit-shift-left were > super-slow under certain circumstances in 1.3. It's a reflection > issue, sure enough, but is it the same issue discussed at ticket #446? http://dev.clojure.org

Deleted clojure-1.3.0-testbuild*-SNAPSHOT artifacts

2011-03-11 Thread Stuart Sierra
I have deleted the Clojure build artifacts with version numbers like "1.3.0-testbuild*-SNAPSHOT" from the public snapshot repository at oss.sonatype.org. This will not affect you unless you use "oss.sonatype.org" as a snapshot repository in your Maven/Ivy/Leiningen builds. If you were using it

Re: clojure 1.3 testbuild1, enlive, and dependency ranges

2011-03-11 Thread Stuart Sierra
I created the testbuild-* artifacts, but they were never uploaded to the Maven Central Repository. I had previously deleted the staging repositories from oss.sonatype.org, and today I deleted the remaining 1.3.0-testbuild*-SNAPSHOT artifacts from oss.sonatype.org. FYI, you can also exclude tra

Re: DOM API for Clojure

2011-03-11 Thread Stuart Sierra
Theoretically, yes, you could build this with Monads. But I'm not the one to ask about that. :) There's also something that Rich Hickey was working on last year called "Pods" or "Cells" -- basically a new reference type that allows safe access to a mutable object. As far as I know, the design

Re: clojure 1.3 testbuild1, enlive, and dependency ranges

2011-03-11 Thread Hugo Duncan
On Fri, 11 Mar 2011 16:40:46 -0500, Stuart Sierra wrote: I created the testbuild-* artifacts, but they were never uploaded to the Maven Central Repository. I had previously deleted the staging repositories from oss.sonatype.org, and today I deleted the remaining 1.3.0-testbuild*-SNAPSHOT

Re: clojure 1.3 testbuild1, enlive, and dependency ranges

2011-03-11 Thread Stuart Sierra
> > I should have mentioned that I had tried both these before posting, and > they don't seem to help in this case. All clojure version artifacts were > still being downloaded. > Huh. That's surprising. Don't know why. *-SNAPSHOT dependency resolution is a bit strange, which is why it's

Re: ANN: Clojure Toolbox (Early Beta)

2011-03-11 Thread James Reeves
Fixed. Thanks for pointing that out! - James On 6 March 2011 19:10, Nebojsa Stricevic wrote: > Greetings, > > First, thanks for setting up Clojure Toolbox. > > Second, ring-json-params link should be fixed. (Missing "s" at the > end.) > > Cheers, > > -- > Nebojša Stričević > > -- > You received

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Armando Blancas
You need to quote the vector so the date will be created inside eval, instead of having the date go into eval as an element of the (evaluated) vector. user=> (eval '[(java.util.Date.)]) [#] On Mar 11, 4:37 pm, Jeffrey Schwab wrote: > What does eval'ing a form containing an object reference cause

RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Jeffrey Schwab
What does eval'ing a form containing an object reference cause an exception? What am I doing wrong? user=> (eval [(java.util.Date.)]) java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: Fri Mar 11 19:33:04 EST 2011 (NO_SOURCE_FILE:153) This is the simplest exam

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Stuart Sierra
`eval` invokes the Clojure compiler, which transforms data structures into Java bytecode. The Clojure compiler understands Clojure data structures like lists, vectors, and symbols, plus a few Java types like String and numbers. It doesn't know what to do with a java.util.Date. "Can't embed o

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Ken Wesson
On Fri, Mar 11, 2011 at 11:12 PM, Armando Blancas wrote: > You need to quote the vector so the date will be created inside eval, > instead of having the date go into eval as an element of the > (evaluated) vector. A more interesting question is "why does this error exist in the first place"? Why

Re: RuntimeException: Can't embed object in code, maybe print-dup not defined

2011-03-11 Thread Ken Wesson
On Fri, Mar 11, 2011 at 11:52 PM, Stuart Sierra wrote: > `eval` invokes the Clojure compiler, which transforms data structures into > Java bytecode.  The Clojure compiler understands Clojure data structures > like lists, vectors, and symbols, plus a few Java types like String and > numbers.  It do