#clojure logs

2008-04-29

08:19pmfI just discovered that Clojure's core data structures do not implement the Serializable-interface and cannot easily be transferred via ObjectOutputStream/ObjectInputStream. Is there an idiomatic way to use the standard Java-serialization or does anyone have a nice way of dealing with this?
08:19rhickeyaddind Serializable support is on the todo list
08:20rhickeyadding
08:22jteothank you, benevolent dictator
08:23pmfOk, nice. (I assume the semantics of serializing structures referring to functions are not all too easy, so I was wondering whether this will be possible at all.)
08:24rhickeyno, functions will remain as difficult to serialize in Clojure as they are everywhere else
08:25rhickeybut vars will work
08:25rhickeywhich helps if your functions are top-level named fns
08:26rhickeythen put vars in your structures instead of fn values, since vars implement IFn by calling their values
11:34Chouseranyone heard anything about the NetBeans plugin that's "due" this month?
11:35ChouserMy hopes for it are probably over-inflated, but I'd love for NetBeans + Clojure to be the "next emacs".
11:38rhickeygave it a test drive yesterday:
11:39rhickeyrepl
11:39rhickeycode navigation panel
11:39rhickeynamespace browser
11:39rhickeydebugging, w/breakpoints, locals
11:40rhickeydocumentation tooltips
11:40rhickeycompletion
11:40rhickeypretty cool
11:40jteointriguing.
11:40Chouserand most of that is implemeneted in Clojure, I believe?
11:40rhickeyyes
11:40Chouser...which gives it a good leg up on that self-hosting stuff that Yegge's on about.
11:41ChouserSo where can I download it? :-)
11:41rhickeyyes, there are actually 2 Clojure instances, one in Netbeans and one for the code you are developing, can toggle the repl to talk to either
11:41Chouseryeah, that sounds Right.
11:42jteoChouser: ah that essay about XEmacs.
11:42rhickeyI think the download will be available this week sometime
11:42rhickeyenclojure.org
11:42Chouserwill it be commercial, do you know?
11:42rhickeyopen source
11:42Chouserexcellent.
11:43rhickeyNetbeans' license(s)
11:43Chouseroh, sure.
11:44ericthorsenWe will have something up for enclojure before the end of the week.
11:45Chouserericthorsen: I'm so excited. there's no way it can live up to my hopes. ;-)
11:46ericthorsenperhaps it can eventually...the possibilities with having a lisp in this environment are giving me very high hopes as to what we can do with this as well...looking forward to feedback
11:50ChouserI've got NetBeans installed and jVi seems to work fine, so I'm ready to go.
11:51rhickeyjVi?
11:52Chouserhttp://jvi.sourceforge.net/
11:53Chouservim clone that can be plugged into NetBeans (and JBuilder).
11:53rhickeyyikes
11:53Chouser:-)
11:54rhickeyThat kind of thing is important though, as people want the benefits of an IDE but can't switch their fingers over to a different system
11:54ChouserIt appears to using the hosting IDE's folding, coloring -- maybe even the full text rendering, and presumablye the file load/save system.
13:55nsinghalI have a function which returns sorted-map - the result is converted to string and streamed back on a socket, it is then evaluated again. PersistentTreeMap is now converted to PersistentHashMap. Is there a reader version of sorted-map?
13:58rhickeyno, but if you control the emit you can emit a call to sorted-map
13:58rhickeyinstead of a map literal
13:59rhickeyare you really eval-ing or just read-ing?
14:01nsinghalits reading
14:01nsinghalnot evaling
14:02rhickeysorry there are no sorted map/set literals yet
14:02nsinghalnp i will send the call to sorted-map, thx
14:03rhickeybut if you are reading you will just get a list with a first item of 'sorted-map
14:08nsinghalright but then subsequent call will get the rest, right
14:08nsinghalthe object will be used then in the regular manner and that should be ok
14:09rhickeyreading (sorted-map :a :b :c :d) yields a list of 5 items, not a sorted-map
14:09nsinghaloh
14:10nsinghalfor now i will sort my map again after streaming.
14:10rhickeyright
14:10nsinghalthx
14:53ericthorsenwhat is the canonical way to convert a map literal to a sorted map?
14:54rhickey(reduce conj (sorted-map) {:a 1 :b 2 :c 3 :d 4})
14:54ericthorsenah...
14:55ericthorsenthanks
14:55rhickeysure
14:56rhickeyalso: (merge (sorted-map) {:a 1 :b 2 :c 3 :d 4})
14:56ericthorsenis one more efficient than the other?
14:57rhickeyand: (conj (sorted-map) {:a 1 :b 2 :c 3 :d 4})
14:58rhickeyericthorsen: not appreciably different
19:10foonesHi, I am just starting with Clojure
19:10rhickeywelcome
19:10foonesI wanted to know if there is a way to combine
19:10foonesload-file + refer
19:11foonesso that I can define functions in different files and namespaces
19:13foonesMaybe I am confused, and there's a smarter way to do this, but I would like somethink like
19:13foones(use foo)
19:13foones== (load-file "foo.clj") (refer 'foo)
19:14rhickeythere is an effort underway in the contrib project building just that, called lib.clj
19:14foonesAhh, I understand
19:14rhickeyhttp://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/lib.clj?view=log
19:14foonesis there a way to get the file?
19:15rhickeyat some point something like this will be rolled into Clojure proper
19:15foones:)
19:15foonesThank you very much
19:15rhickeysure
19:19gomer-nycI noticed someone asked about serialization this morning.
19:20gomer-nycI am working on a project at the moment where I serialize data, mostly maps, and other "basic" clojure data structures.
19:21rhickeyserialize via what mechanism?
19:21gomer-nycI use the traditional lisp approach of (pr-str) to generate a string representation and then simply (read) to reconstruct the data
19:21rhickeyah, the easy way :)
19:22gomer-nyc:-) yeah, it is working pretty well
19:22rhickeyI can see the need for Serializable support, given the many libraries that require it
19:22gomer-nycright
19:23rhickeyread/print is nice to have, and I want to extend it towards Java types too, probably via JavaBeans' (XML) serialization
19:23gomer-nycI'm working on an interface to Berkeley DB and do not need the Serializable support.
19:23gomer-nycHmmm, that would be very interesting.
19:24gomer-nycI don't really know anything about Beans
19:32rhickeygomer-nyc: decent article - http://jdj.sys-con.com/read/37550.htm
19:41gomer-nycok cool. Looks pretty straightforward
19:42rhickeyI think so, but have never used it. Being text -based, it's a good fit for read/print
19:45gomer-nycI have a question on a different matter
19:46gomer-nycHave read in the newsgroup about your position on keyword arguments for functions
19:47gomer-nycthis is a somewhat related question - what do you think about support for default values for optional params?
19:48gomer-nyccurrently I'm using overloads to essentially accomplish this, and of course I can have a macro that does it for me, but just curious
19:50rhickeyit will always be macrology, I'm happy with invoke() as is. I had keywords/optionals just like CL in an earlier incarnation
19:51gomer-nycok
19:52rhickeyoverloads are a big perf win
19:52gomer-nycright, I love having it.
19:53rhickeyand allow inner params to be optional
19:56gomer-nycgreat; well, let me get back to my clojure hacking. thanks for your time!