#clojure log - Apr 29 2008

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

8:19 pmf: I 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?

8:19 rhickey: addind Serializable support is on the todo list

8:20 adding

8:22 jteo: thank you, benevolent dictator

8:23 pmf: Ok, 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.)

8:24 rhickey: no, functions will remain as difficult to serialize in Clojure as they are everywhere else

8:25 but vars will work

8:25 which helps if your functions are top-level named fns

8:26 then put vars in your structures instead of fn values, since vars implement IFn by calling their values

11:34 Chouser: anyone heard anything about the NetBeans plugin that's "due" this month?

11:35 My hopes for it are probably over-inflated, but I'd love for NetBeans + Clojure to be the "next emacs".

11:38 rhickey: gave it a test drive yesterday:

11:39 repl

11:39 code navigation panel

11:39 namespace browser

11:39 debugging, w/breakpoints, locals

11:40 documentation tooltips

11:40 completion

11:40 pretty cool

11:40 jteo: intriguing.

11:40 Chouser: and most of that is implemeneted in Clojure, I believe?

11:40 rhickey: yes

11:40 Chouser: ...which gives it a good leg up on that self-hosting stuff that Yegge's on about.

11:41 So where can I download it? :-)

11:41 rhickey: yes, 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:41 Chouser: yeah, that sounds Right.

11:42 jteo: Chouser: ah that essay about XEmacs.

11:42 rhickey: I think the download will be available this week sometime

11:42 enclojure.org

11:42 Chouser: will it be commercial, do you know?

11:42 rhickey: open source

11:42 Chouser: excellent.

11:43 rhickey: Netbeans' license(s)

11:43 Chouser: oh, sure.

11:44 ericthorsen: We will have something up for enclojure before the end of the week.

11:45 Chouser: ericthorsen: I'm so excited. there's no way it can live up to my hopes. ;-)

11:46 ericthorsen: perhaps 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:50 Chouser: I've got NetBeans installed and jVi seems to work fine, so I'm ready to go.

11:51 rhickey: jVi?

11:52 Chouser: http://jvi.sourceforge.net/

11:53 vim clone that can be plugged into NetBeans (and JBuilder).

11:53 rhickey: yikes

11:53 Chouser: :-)

11:54 rhickey: That 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:54 Chouser: It appears to using the hosting IDE's folding, coloring -- maybe even the full text rendering, and presumablye the file load/save system.

13:55 nsinghal: I 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:58 rhickey: no, but if you control the emit you can emit a call to sorted-map

13:58 instead of a map literal

13:59 are you really eval-ing or just read-ing?

14:01 nsinghal: its reading

14:01 not evaling

14:02 rhickey: sorry there are no sorted map/set literals yet

14:02 nsinghal: np i will send the call to sorted-map, thx

14:03 rhickey: but if you are reading you will just get a list with a first item of 'sorted-map

14:08 nsinghal: right but then subsequent call will get the rest, right

14:08 the object will be used then in the regular manner and that should be ok

14:09 rhickey: reading (sorted-map :a :b :c :d) yields a list of 5 items, not a sorted-map

14:09 nsinghal: oh

14:10 for now i will sort my map again after streaming.

14:10 rhickey: right

14:10 nsinghal: thx

14:53 ericthorsen: what is the canonical way to convert a map literal to a sorted map?

14:54 rhickey: (reduce conj (sorted-map) {:a 1 :b 2 :c 3 :d 4})

14:54 ericthorsen: ah...

14:55 thanks

14:55 rhickey: sure

14:56 also: (merge (sorted-map) {:a 1 :b 2 :c 3 :d 4})

14:56 ericthorsen: is one more efficient than the other?

14:57 rhickey: and: (conj (sorted-map) {:a 1 :b 2 :c 3 :d 4})

14:58 ericthorsen: not appreciably different

19:10 foones: Hi, I am just starting with Clojure

19:10 rhickey: welcome

19:10 foones: I wanted to know if there is a way to combine

19:10 load-file + refer

19:11 so that I can define functions in different files and namespaces

19:13 Maybe I am confused, and there's a smarter way to do this, but I would like somethink like

19:13 (use foo)

19:13 == (load-file "foo.clj") (refer 'foo)

19:14 rhickey: there is an effort underway in the contrib project building just that, called lib.clj

19:14 foones: Ahh, I understand

19:14 rhickey: http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/lib.clj?view=log

19:14 foones: is there a way to get the file?

19:15 rhickey: at some point something like this will be rolled into Clojure proper

19:15 foones: :)

19:15 Thank you very much

19:15 rhickey: sure

19:19 gomer-nyc: I noticed someone asked about serialization this morning.

19:20 I am working on a project at the moment where I serialize data, mostly maps, and other "basic" clojure data structures.

19:21 rhickey: serialize via what mechanism?

19:21 gomer-nyc: I use the traditional lisp approach of (pr-str) to generate a string representation and then simply (read) to reconstruct the data

19:21 rhickey: ah, the easy way :)

19:22 gomer-nyc: :-) yeah, it is working pretty well

19:22 rhickey: I can see the need for Serializable support, given the many libraries that require it

19:22 gomer-nyc: right

19:23 rhickey: read/print is nice to have, and I want to extend it towards Java types too, probably via JavaBeans' (XML) serialization

19:23 gomer-nyc: I'm working on an interface to Berkeley DB and do not need the Serializable support.

19:23 Hmmm, that would be very interesting.

19:24 I don't really know anything about Beans

19:32 rhickey: gomer-nyc: decent article - http://jdj.sys-con.com/read/37550.htm

19:41 gomer-nyc: ok cool. Looks pretty straightforward

19:42 rhickey: I think so, but have never used it. Being text -based, it's a good fit for read/print

19:45 gomer-nyc: I have a question on a different matter

19:46 Have read in the newsgroup about your position on keyword arguments for functions

19:47 this is a somewhat related question - what do you think about support for default values for optional params?

19:48 currently 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:50 rhickey: it will always be macrology, I'm happy with invoke() as is. I had keywords/optionals just like CL in an earlier incarnation

19:51 gomer-nyc: ok

19:52 rhickey: overloads are a big perf win

19:52 gomer-nyc: right, I love having it.

19:53 rhickey: and allow inner params to be optional

19:56 gomer-nyc: great; well, let me get back to my clojure hacking. thanks for your time!

Logging service provided by n01se.net