2008-09-01
| 10:09 | joubert | Hi, I have a question regarding the design of StructMaps |
| 10:12 | rhickey | joubert: ok |
| 10:15 | joubert | Hi Rich. One can serialize vectors via Java's ObjectOutputStream, but cannot do so with StructMaps |
| 10:16 | rhickey | joubert: I haven't done any work on serialization of Clojure's data structures |
| 10:20 | joubert | rhickey: right, I understand. It seems that persistence works (automagically) for some data structures, but not for seqs currently. |
| 10:23 | rhickey | joubert: 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:24 | joubert | rhickey: ok |
| 12:10 | blackdog_ | if I use (load file "sql.clj") should i be able to say (ns :use [clojure.contrib.sql :as sql]) or something similar? |
| 12:10 | blackdog_ | i.e. can the new libs work with the old system? |
| 12:12 | blackdog_ | nevermind, it works |
| 12:13 | rhickey | blackdog_: it's best to get away from load-file ASAP, put your code in the classpath and use use/require or load-resource |
| 12:14 | blackdog_ | yes, I'm doing that now, and am in a limbo state :) |
| 14:22 | achim_p | hi! |
| 14:22 | achim_p | i must admit lazy seqs disturb me a little :) |
| 14:22 | achim_p | any ideas why this throws a NullPointerException when taking more than 1 element ...: |
| 14:22 | achim_p | (def lots-of-1s (lazy-cons 1 lots-of-1s)) |
| 14:23 | achim_p | while this doesn't?: |
| 14:23 | achim_p | (def lots-of-1s (lazy-cons 1 (map identity lots-of-1s))) |
| 14:34 | jgracin | I'm not sure, but I think Clojure evals one value in advance |
| 14:45 | achim_p | jgracin: 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:47 | achim_p | i should probably get some haskell books ;) |
| 15:24 | rhickey | achim_p: that was a bug, now fixed (in rev 1014) |
| 15:25 | rhickey | user=> (take 10 lots-of-1s) |
| 15:25 | rhickey | (1 1 1 1 1 1 1 1 1 1) |
| 16:45 | jamii | how 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:46 | rhickey | I 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:47 | jamii | cheers, ill have a look at the java utils. |
| 17:15 | arohner | is pred.clj missing (map?) |
| 17:15 | arohner | it appears so |
| 17:15 | arohner | (defn map? [x] (instance? clojure.lang.IPersistentMap x)) |
| 17:18 | arohner | duh. it's not in pred.clj because it's built in |
| 17:41 | achim_p | rhickey: okay, thanks! |
| 18:10 | lisppaste8 | jamii pasted "qt-repl" at http://paste.lisp.org/display/66179 |
| 18:10 | jamii | Could someone take a look at this? There must be a better way of doing this |
| 18:19 | arohner | how do you use set! on a java field? |
| 18:19 | arohner | (def r 22/7) |
| 18:20 | arohner | user=> (set! (. r numerator) 23) |
| 18:20 | arohner | (set! (. r numerator) 23) |
| 18:20 | arohner | java.lang.ClassCastException |
| 18:20 | arohner | java.lang.ClassCastException |
| 18:20 | arohner | at java.lang.Class.cast(Class.java:2951) |
| 18:20 | arohner | at clojure.lang.Reflector.boxArg(Reflector.java:330) |
| 18:20 | arohner | at clojure.lang.Reflector.setInstanceField(Reflector.java:235) |
| 18:20 | rhickey | numerator is final |
| 18:20 | rhickey | why not make a new ratio? |
| 18:21 | arohner | yeah, that would work. I was more curious to see if I could do it |
| 18:21 | rhickey | you can for non-final fields - good luck finding one! |
| 18:22 | arohner | :-) |
| 18:22 | arohner | is there a way to create a ratio with a zero in the numerator or denominator? |
| 18:23 | arohner | what I'm trying to do is go through a list, and count up the number of items that match some predicates |
| 18:23 | arohner | and I want a percentage at the end, but it would be nice to say 0 out of X matched |
| 18:53 | achim_p | arohner: if you really want to do this - (clojure.lang.Ratio. (bigint 0) (bigint 0)) |
| 18:54 | arohner | achim_p: thanks |