#clojure logs

2008-09-01

10:09joubertHi, I have a question regarding the design of StructMaps
10:12rhickeyjoubert: ok
10:15joubertHi Rich. One can serialize vectors via Java's ObjectOutputStream, but cannot do so with StructMaps
10:16rhickeyjoubert: I haven't done any work on serialization of Clojure's data structures
10:20joubertrhickey: right, I understand. It seems that persistence works (automagically) for some data structures, but not for seqs currently.
10:23rhickeyjoubert: I don't doubt that, but unless there's something trivial I can do to enable that, it remains part of the 'enable serialization of all data structures' todo item
10:24joubertrhickey: ok
12:10blackdog_if I use (load file "sql.clj") should i be able to say (ns :use [clojure.contrib.sql :as sql]) or something similar?
12:10blackdog_i.e. can the new libs work with the old system?
12:12blackdog_nevermind, it works
12:13rhickeyblackdog_: it's best to get away from load-file ASAP, put your code in the classpath and use use/require or load-resource
12:14blackdog_yes, I'm doing that now, and am in a limbo state :)
14:22achim_phi!
14:22achim_pi must admit lazy seqs disturb me a little :)
14:22achim_pany ideas why this throws a NullPointerException when taking more than 1 element ...:
14:22achim_p(def lots-of-1s (lazy-cons 1 lots-of-1s))
14:23achim_pwhile this doesn't?:
14:23achim_p(def lots-of-1s (lazy-cons 1 (map identity lots-of-1s)))
14:34jgracinI'm not sure, but I think Clojure evals one value in advance
14:45achim_pjgracin: i think you're right, but while i see why taking the first element works in both cases, i don't see why it doesn't work for more than one with the first def. and i don't see why wrapping the seq in a map call makes a difference, as map yields a lazy sequence as well ...
14:47achim_pi should probably get some haskell books ;)
15:24rhickeyachim_p: that was a bug, now fixed (in rev 1014)
15:25rhickeyuser=> (take 10 lots-of-1s)
15:25rhickey(1 1 1 1 1 1 1 1 1 1)
16:45jamiihow would i write a function that block until a given ref is not nil? is there a way to force the current transaction to retry, for example?
16:46rhickeyI don't advocate tying workflow to transactions - you can use queues or latches from java.util.concurrent and save the transaction for when you have work to do
16:47jamiicheers, ill have a look at the java utils.
17:15arohneris pred.clj missing (map?)
17:15arohnerit appears so
17:15arohner(defn map? [x] (instance? clojure.lang.IPersistentMap x))
17:18arohnerduh. it's not in pred.clj because it's built in
17:41achim_prhickey: okay, thanks!
18:10lisppaste8jamii pasted "qt-repl" at http://paste.lisp.org/display/66179
18:10jamiiCould someone take a look at this? There must be a better way of doing this
18:19arohnerhow do you use set! on a java field?
18:19arohner (def r 22/7)
18:20arohneruser=> (set! (. r numerator) 23)
18:20arohner(set! (. r numerator) 23)
18:20arohnerjava.lang.ClassCastException
18:20arohnerjava.lang.ClassCastException
18:20arohner at java.lang.Class.cast(Class.java:2951)
18:20arohner at clojure.lang.Reflector.boxArg(Reflector.java:330)
18:20arohner at clojure.lang.Reflector.setInstanceField(Reflector.java:235)
18:20rhickeynumerator is final
18:20rhickeywhy not make a new ratio?
18:21arohneryeah, that would work. I was more curious to see if I could do it
18:21rhickeyyou can for non-final fields - good luck finding one!
18:22arohner:-)
18:22arohneris there a way to create a ratio with a zero in the numerator or denominator?
18:23arohnerwhat I'm trying to do is go through a list, and count up the number of items that match some predicates
18:23arohnerand I want a percentage at the end, but it would be nice to say 0 out of X matched
18:53achim_parohner: if you really want to do this - (clojure.lang.Ratio. (bigint 0) (bigint 0))
18:54arohnerachim_p: thanks