Re: 'first vs 'nth on maps

2009-04-20 Thread Hugh Winkler
not supported on this type: PersistentArrayMap (NO_SOURCE_FILE:0)  [Thrown class clojure.lang.Compiler$CompilerException] Thanks, Hugh -- Hugh Winkler, CEO Wellstorm Development 31900 Ranch Road 12 Suite 206 Dripping Springs, TX 78620 USA http://www.wellstorm.com/ +1 512 264 3998 x801

Re: No I/O in STM transactions?

2009-04-06 Thread Hugh Winkler
think it is a strategy that you can use. Yes, thanks very much for this tip! I have to admit I didn't (don't) understand the agent concept. I've been avoiding the subject I guess. Going to have a look now... On Apr 5, 2:11 pm, Hugh Winkler hwink...@gmail.com wrote: Hi all, Fromhttp

No I/O in STM transactions?

2009-04-05 Thread Hugh Winkler
Hi all, From http://clojure.org/refs : I/O and other activities with side-effects should be avoided in transactions, since transactions will be retried. The io! macro can be used to prevent the use of an impure function in a transaction. Isn't it OK to do I/O in a transaction as long as doing

Re: Unexpected binding behavior

2009-01-20 Thread Hugh Winkler
On Mon, Jan 19, 2009 at 11:01 PM, Stuart Halloway stuart.hallo...@gmail.com wrote: Lazy evaluation is a harsh mistress. user= (def b1 (binding [*num* 1024] (f1))) #'user/b1 user= (def b2 (binding [*num* 1024] (f1))) #'user/b2 user= b1 (16) user= b2 (16) The difference between the

Re: Unexpected binding behavior

2009-01-20 Thread Hugh Winkler
On Tue, Jan 20, 2009 at 11:45 AM, Stuart Halloway stuart.hallo...@gmail.com wrote: OK, good, thanks for the explanation. Is it desirable behavior? Is there some case where a programmer wants this behavior? It's pretty scary to have to consider these hidden effects. Sort of the opposite of

Re: Unexpected binding behavior

2009-01-20 Thread Hugh Winkler
On Tue, Jan 20, 2009 at 12:53 AM, Timothy Pratley timothyprat...@gmail.com wrote: How would one go about fixing f1 (or b1)? Depends what you want to achieve... here are two possible 'fixes': ; don't use lazy evaluation (defn f1 [] (doall (map (fn [x] *num* ) [1]))) ; use lazy

Unexpected binding behavior

2009-01-19 Thread Hugh Winkler
Hi all. Is this a bug or a feature? When I bind the var *num* to a new value, in one case it appears the lambda uses the original value, not the newly bound one. (def *num* 16) (defn f1 [] ( map (fn [x] *num* ) [1])) (defn f2 [] ;; same as f1 but calls first on the map (first (

Problem using fn macro

2009-01-15 Thread Hugh Winkler
I just encountered a surprise attempting to return a function from a function. In the below case, if the function parameter is named fn, then calling the function throws an exception. If the function parameter is named f, no problem. (Using svn as of yesterday) (defn no-problem[f] (fn []

Re: Problem using fn macro

2009-01-15 Thread Hugh Winkler
in to the arguments. the function you passed in takes no arguments so you get the Wrong number of args passed to exception. On Jan 15, 11:12 am, Hugh Winkler hwink...@gmail.com wrote: I just encountered a surprise attempting to return a function from a function. In the below case, if the function parameter

Java arrays caveat -- why?

2009-01-02 Thread Hugh Winkler
From http://clojure.org/java_interop#toc27 : Clojure supports the creation, reading and modification of Java arrays. It is recommended that you limit use of arrays to interop with Java libraries that require them as arguments or use them as return values. What are the reasons for this caveat?

Re: making code readable

2009-01-01 Thread Hugh Winkler
I hesitate to extend this unpleasant thread, but here's a relevant post that definitely takes a stand on the commenting issue: http://steve-yegge.blogspot.com/2008/02/portrait-of-n00b.html As usual with Steve, it's a funny post, so I hope nobody takes it too seriously :) Hugh On Wed, Dec 31,