Re: Nil Coalesce

2010-08-17 Thread Dave Jack
Neither particularly short nor particularly clever: (defn nil-coalesce [coll subs] (loop [[c cs :as coll] coll [s ss :as subs] subs acc []] (if coll (recur cs (if (nil? c) ss subs) (conj acc (if (nil? c) s c))) acc))) On Tue, Aug

Re: Weird Segmentation fault while running Clojure

2010-07-30 Thread Dave Jack
I did some Googling and came across this: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6366468 It implicates jar file corruption, possibly caused by modifying jar files while the VM is running. Seems consistent with the ZipFile/URLClassLoader entries in the stack trace. j

Re: Request for comments: DefaultMap

2010-07-08 Thread Dave Jack
Hi Michal, I needed to change your containsKey implementation to always return true in order to support the merge-with use case. Hi Stu, merge-with* seems like a useful addition, though its semantics differ slightly from merge-with's. The original merge-with modifies the vals only if there are

clojure.contrib.shell broken with clojure commit 37d8f7a

2010-05-10 Thread Dave Jack
clojure.core/byte was modified a couple weeks ago as follows: (defn byte Coerce to byte {:tag Byte :inline (fn [x] `(. clojure.lang.RT (byteCast ~x)))} - [^Number x] (. x (byteValue))) + [^Number x] (clojure.lang.RT/byteCast x)) byteValue and byteCast behave differently with

Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack
When it useful to be able to deref inside a dosync without ensuring? When you deref and alter/set the same ref, the ref is protected from modification as well. I couldn't think of an example of what I think you had in mind, something that requires a transaction but is tolerant of modification

Re: Q: is there a better way to do this

2009-09-23 Thread Dave Jack
On Sep 23, 9:23 am, Dave Jack dav...@gmail.com wrote: Maybe @ should expand to ensure rather than deref inside a transaction, instead? Should've thought about this more. How is the reader supposed to know that this code is called in a transaction? And it would leak if you deref'd inside