#clojure log - May 17 2009

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

2:22 Serkan: hi

2:25 stuhood: heya

2:27 Serkan: what's the version of asm bundled with clojure 1.0, and is it a modified copy?

2:29 hiredman: ~def clojure.asm.ClassWriter

2:30 stuhood: according to SVN, it hasn't been modified since Dec 2007

2:31 hiredman: which is maybe around the time the switch to google code happened?

2:32 danlarkin_: 2007?

2:32 Serkan: any maintainers arounmd?

2:33 hiredman: oh

2:33 right 2007

2:35 Serkan: I am kind of curious, why are you asking about asm?

2:35 stuhood: Serkan: this thread is right before the check-in of ASM, and it implies that 3.0 is in use: http://groups.google.com/group/clojure/browse_thread/thread/ccfb84854d79809f/758ba8979f43578d?lnk=gst&q=asm&pli=1

2:53 Serkan: hiredman: I'm a Gentoo trying to package clojure

2:53 hiredman: and you want to split out clojure.asm.*?

2:53 Serkan: I'll use the system asm library if the bundled one isn't a modified version

2:54 ah the package structure is different as well :(

2:54 hiredman: Serkan: as rhickey mentions in that google group posting, a lot of projects use asm, so to avoid conflicts

2:55 I would just grab the zip file, extract clojure.jar and forget about it

2:56 Serkan: hiredman, stuhood thanks for the pointers

2:56 stuhood: no problem... glad to see Clojure making it into Gentoo

3:00 Serkan: though I need to ask the others if they're OK with bundled asm.

3:05 cads_: are you going to bundle bash startup scripts and such?

3:07 Serkan: cads_: ?

3:07 was that for me

3:07 cads_: yeah, I was just wondering about how clojure will be packaged in gentoo

3:08 I've been thinking about making a deb

3:08 Serkan: I'm making a luancher that runs clojure.lang.Repl

3:09 danlarkin_: Serkan: clojure.lang.Repl is old and busted, use clojure.main

3:09 Serkan: check out http://code.google.com/p/clojure-contrib/source/browse/trunk/launchers/bash/clj-env-dir for a good example

3:14 Serkan: danlarkin_: I see. I guess I found this in homepage

3:19 danlarkin_: fixed http://overlays.gentoo.org/proj/java/changeset/7762

3:20 danlarkin_: Serkan: cool :)

4:37 unlink: Bah. No UNIX sockets in Java?

4:37 stuhood: the api isn't identical, but you can use raw sockets

4:38 unlink: What do you mean "raw"?

4:38 As in TCP/IP?

4:38 stuhood: no, sorry, not sure what i meant

4:38 http://java.sun.com/javase/6/docs/api/java/net/Socket.html

4:38 p_l: raw sockets usually mean directly writing to device...

4:39 unlink: Yeah, those look like TCP/IP sockets.

4:40 markusgustavsson: I don't think java supports raw sockets

4:40 stuhood: sorry... i didn't mean raw sockets.

4:45 unlink: I'm looking for something along the lines of http://u.nu/5g46 ...surely some library exists

4:45 Serkan: unlink: libmatthew-java has

4:48 unlink: Thanks...hmm, it's missing from my repo

4:49 Serkan: unlink: http://www.matthew.ath.cx/projects/java/

4:50 hiredman: you could use chouser's jna lib

4:51 unlink: No wonder I couldn't find it. ath.cx

4:51 hiredman: "Dynamically load and use native C libs from Clojure using JNA"

4:51 http://github.com/Chouser/clojure-jna/tree/master

4:52 unlink: What C library did you have in mind? libc?

4:53 hiredman: yeah

4:53 open()

4:55 wow

4:55 it has been a long time since I have written any C

4:56 unlink: import cx.ath.matthew.unix.UnixSocket; is mad sketchy

4:57 hiredman: how so?

4:57 unlink: import cx.ath. ...

4:57 dyndns

4:58 though I actually intended that message for another tab

4:58 hiredman: I had a .cx back in the day

4:59 ah

8:31 guinea: I'm just wondering, is a zipper how the emacs buffer works?

8:32 kotarak: The Yi buffers seem to work like a zipper. Dunno about emacs.

11:32 Qvintvs: does the clojure have some sort of (exit) function to get out of the interpreter, or do you just need to ctrl+c out of it?

11:32 does clojure*

11:33 dreish: You could do (System/exit 0)

11:35 Qvintvs: yay, ty

12:06 Chouser: unlink: I'd actually recommed using jna on libc curerntly, over that libmatthew thing.

12:08 p_l: Chouser: it might even work on Windows, I think :)

12:08 Chouser: I'm pretty sure Windows doesn't have unix domain sockets.

12:10 * p_l just loves screwing around people's minds with Unix Domain Sockets working on Windows (they do)

12:11 p_l: it's just non-standard optional package

12:11 Chouser: huh

12:11 p_l: just like there's a setting that changes the whole system into case-sensitive, including devfs (which can break various code)

12:13 oh, and the MS installer of SUA (Services for Unix Applications) includes GCC

12:56 markusgustavsson: So what's the jna performance like? Same as regular jni?

13:19 grosours: plop

13:42 Chouser: markusgustavsson: https://jna.dev.java.net/#performance

13:48 so, no, not as fast as jni. :-)

13:58 guinea: Is it possible to do something like a proxy of a proxy? i.e. use proxy to overload some methods, and then do another proxy on that to overload more functions - a sort of inheritance

14:00 Chouser: proxy takes a class and returns an instance.

14:00 guinea: hmm

14:01 Chouser: I guess I'm not sure what you're trying to do. A proxy can't add methods...

14:01 guinea: i'll have to write a macro to combine overloadings into a proxy statement...

14:02 I've written different proxies, to overload a java class in various ways

14:02 and I want to be able to create proxies that have combinations of those

14:02 Chouser: if you look at the proxy macro source, you'll see it does a lot of its work at runtime with a couple public functions

14:02 guinea: cool

14:02 Chouser: each proxy instance has a map of the functions it will call for the various methods. you may be able to work with those directly.

14:02 guinea: where do I find the macro source?

14:03 Chouser: maybe not even need to write a macro

14:03 ~def proxy

14:03 or (source proxy) if you have clojure.contrib.repl-utils

14:03 guinea: sweet

14:03 * guinea loves clojurebot

14:04 Chouser: gotta go mow. ciao.

14:04 guinea: thx

15:25 quidnunc: Anyone at all familiar with enlive?

15:26 dnolen: yes

15:35 quidnunc: dnolen: If I want to select a table node with class "bar" shouldn't [:table (attr= :class "bar")] work?

15:36 [:table (attr? :class)] seems to return more results than just [:table}

15:37 dnolen: isn't there a has-class?

15:38 quidnunc really it should be

15:38 [:table.bar]

15:39 [:table (attr? :class)] will return any table that has a class attribute not just bar.

15:39 quidnunc: dnolen: It does a union?

15:39 dnolen: no it's how CSS3 works

15:39 table.bar matches a table with class bar

15:40 [:table.bar] is the enlive translation.

15:40 quidnunc: dnolen: I meant [:table (attr? :class)]

15:40 That does a union?

15:40 dnolen: I suppose so, but it simply means "return all tables that have a class attribute"

15:42 quidnunc: By union I meant table OR class attribute. Shouldn't this work: [:table (attr= :class "bar")]

15:42 dnolen: ?

15:42 you want all tables or anything with a class attribute?

15:42 quidnunc: I want table with class attribute "bar baz"

15:42 tables*

15:43 dnolen: [:table (has-class "bar baz")] should work I think.

15:46 lisppaste8: quidnunc pasted "enlive class selector" at http://paste.lisp.org/display/80388

15:46 quidnunc: dnolen: ^ It doesn't seem to

15:47 dnolen: oops

15:47 the docs say

15:48 [:table.bar.baz]

15:49 quidnunc: dnolen: Ah, good. Works now.

15:49 dnolen: Thanks. That was driving me a bit up the wall.

15:49 dnolen: np

15:50 quidnunc: That seems a bit nasty though. How do you deal with dynamic class names?

15:51 (has-class "bar" "baz") doesn't seem to work.

15:52 (and splitting the args into separate strings every time is unpleasant)

15:53 Actually, I'm surprised that what I initially tried didn't work. Shouldn't class be treated like any other attribute?

15:59 danlarkin_: quidnunc: I think the main thing is that an element can have many classes, and usually you just want to check for one, not one and only one

15:59 mcspiff: anyone feel up to helping a newbie get slime setup?:D

16:01 quidnunc: danlarkin_: So their is no distinction in enlive between class="foo bar" and class="foo" class="bar"?

16:01 there*

16:04 danlarkin_: quidnunc: in enlive? I don't know, there probably is. I'm just saying why it's the way it is

16:05 quidnunc: danlarkin_: Okay, thanks.

16:11 mattikus: Is there a decent way to catch ctrl-c from the repl and have it not exit?

16:27 liebke: mattikus: clojure.contrib.repl-utils/add-break-thread! used to do that, but it doesn't seem to work anymore. Something must of have changed

16:28 mattikus: Shucks. I'm so used to ctrl-c being either clear line or break current execution that I keep kicking myself out of the interpreter.

16:32 fyuryu: StartsWithK: Hi

16:33 liebke: yeah, I call add-break-thread! in my user.clj, so ctrl-c used to automatically work "correctly". I need to figure out what the problem is.

16:35 fyuryu: StartsWithK: I added an ant file for cloak, turned out I needed it anyway - the setup that I was using was not completely safe - sometimes I had problems with compilation.

16:58 StartsWithK: fyuryu: oh, hi, i wasn't here

16:59 fyuryu: i forked it on github (i guess that is what i did), added ivy build so it downloads clojure from .zip on download page (packager resolver) and it can compile itself in one go

16:59 fyuryu: also imported some of your code from your libs project, i think is down to graph and utils now

17:00 fyuryu: also removed test-is and replaced it with my fork of clj-unit so test can be peformed with build

17:00 fyuryu: and replaced some of your code with stuff from commons-io, like mkdir and such

17:00 now i have a problem, i did it i know, tests fail

17:00 but i think i can fix that tomorow

17:01 fyuryu: StartsWithK: ah, I somehow missed that github clone

17:02 StartsWithK: so next step would be ant task for compiling clojure sources in a way javac does it

17:03 i have such a task for ant but it is in javascript, and i was planing to port it to pure clojure

17:03 so i can use read with eval = false to realy check for namespace names

17:03 i would like to place that code in cloak instead of my project

17:04 and if someone realy (realy realy) needs it, i would also try a joint java-clojure compiler, but for now i don't have any interest in it myself

17:05 will you accept that patches too?

17:06 fyuryu: StartsWithK: <StartsWithK> so i can use read with eval = false to realy check for namespace

17:06 names --- not sure I understand that part

17:08 StartsWithK: fyuryu: http://paste.pocoo.org/show/117753/

17:08 fyuryu: in my clojurec task i just check for "(ns" to decide is .clj file with namespace declaration or maybe it uses (in-ns), but that is weak

17:09 it dosn't work if you type ;(ns blah..)

17:09 anyway that task works like <clojurec srcdir='' destdir=''/> so you don't need to write namespaces you would like to compile

17:10 fyuryu: StartsWithK: Ah, I get it now

17:11 StartsWithK: fyuryu: i would like this new task to be inside cloak (with clojure-repl task) and after that i would add ant wrapper to cloak

17:12 fyuryu: StartsWithK: sounds cool. I was also thinking about about those topics and found that there's no way around ant. It has to be part of the toolbox.

17:14 StartsWithK: fyuryu: yes, and by providing a ant taks we would get support (in a way) for buildr, gradle and such as they all can use ant task in there builds.

17:14 i looked at what lanced did, but that will not work, ant task are much more complex and can be registered at any time to project instance

17:14 djkthx: whats the equivalent to member in clojure?

17:14 from common lisp?

17:15 fyuryu: StartsWithK: I found your repo on github, I'll try to find time during the week/weekend to look at it

17:16 StartsWithK: fyuryu: thanks, just don't merge, its not functional for now.. well i guess i could go now and try to fix it :)

17:19 fyuryu: StartsWithK: ok

17:22 danlarkin_: Chouser: did you see my post in the error-kit + test-is thread? Any thoughts?

17:47 dfdeshom: hi, is there a way to build objects in clojure? something like the clos comes to mind

17:48 opqdonut: proxy

17:49 http://clojure.org/java_interop#toc25

17:49 dreish: There's nothing like CLOS. The usual thing is to use hashes and multimethods.

17:50 opqdonut: yeh

17:53 dfdeshom: can I define custom operators for my types? Eg for ^,&, etc

17:58 danlarkin_: dfdeshom: that's a loaded question... short answer is yes, but not for certain symbols... ^ is reserved by the reader already, and +,-, etc are already defined in clojure.core

18:00 StartsWithK: dfdeshom: you could also take a look at clojure.contrib.generic library

18:01 dfdeshom: thanks guys.

18:02 I'm asking this because I saw a scala program doing operator overloading and I wanted to know how clojure does this, if at all

18:03 dreish: Scala and Clojure are extremely different languages.

18:08 dfdeshom: that's what i'm finding out :) . i like scala because i can use objects and clojure because it's dynamic in nature. they both have things that annoy me but i'm trying to find out which one gets in my way of thinking less

18:36 StartsWithK: dfdeshom: there are some libraries for clojure that let you program in oo style, i think spinoza (http://github.com/swannodette/spinoza/tree/master) is one of the more complete ones

19:05 dfdeshom: StartsWithK: thanks for the link. this is not a deal-breaker for me, i just want to know what's "easy" and "hard" to do w/ clojure

19:58 bpattison: can anyone tell me what the last statement is false?

19:58 user=> (= () '())

19:58 true

19:58 user=> (= {:x ()} {:x '()})

19:58 true

19:58 user=> (= {:x '({:y ()})} {:x '({:y '()})} )

19:58 false

19:58 it seems like it should be true as well

20:00 rhickey: (:y '{:y '()})

20:00 ,(:y '{:y '()})

20:00 clojurebot: (quote ())

20:00 rhickey: (:y '{:y ()})

20:00 ,(:y '{:y '()})

20:00 clojurebot: (quote ())

20:01 rhickey: ,(:y '{:y ()})

20:01 clojurebot: ()

20:01 rhickey: the outer quote prevent the inner one from being evaluated

20:01 prevents

20:02 bpattison: oh -- so the outer quote is applying to the rest of the statement -- okay thanks

20:02 and I don't need to quote the inner one

20:03 rhickey: bpattison: right

20:04 '() is always unnecessary, just use ()

20:04 bpattison: okay, that really helps me understand what's going on --thanks

22:49 chessguy: are merge and merge-with about the only way to combine 2 maps?

22:53 abrooks: chessguy: You can also conj two maps with the latter taking precedence: (conj {:a 1 :c 3 :b 42} {:b 2 :d 4})

22:53 ,(conj {:a 1 :c 3 :b 42} {:b 2 :d 4})

22:53 clojurebot: {:d 4, :a 1, :c 3, :b 2}

22:55 chessguy: hmm

22:57 abrooks: In fact, I'm having trouble thinking how merge is any different than conj without going and looking at core.clj.

22:57 chessguy: so there's no good way to conj the two together, applying some uniquifying function to any key that's a duplicate

22:58 abrooks: chessguy: That's what merge-with is for.

22:58 chessguy: no, i want both the original key and a uniqified version to be in the result

22:58 abrooks: chessguy: The function you specify allows you to handle the duplicats.

22:59 chessguy: Under the same key? You can't, the key must be unique in the map.

22:59 chessguy: You can merge the values and that's what it does.

22:59 chessguy: sorry, i'm clearly not making myself clear

23:00 i want something like (my-merge uniquifier {:a 1} {:a 1}) => {:a 1 :a_ 1}

23:00 hiredman: chessguy: sounds like you want to wrap assoc

23:00 unlink: Man, I'm so glad I found repl-utils/javadoc ... I was about to write that

23:00 hiredman: or wrap merge

23:00 chessguy: where uniquifier figures out how to generate the new symbol

23:01 hiredman, hm. maybe wrap merge to be able to add a sequence of symbols to the resulting map?

23:02 hiredman: ,(assoc {:a 1} :a 1 :b 2)

23:02 clojurebot: {:b 2, :a 1}

23:03 hiredman: so you just wrap assoc to generate uniquefied keys for keys already in the keyset

23:03 ,(.keySet #{:a})

23:03 clojurebot: java.lang.IllegalArgumentException: No matching field found: keySet for class clojure.lang.PersistentHashSet

23:03 hiredman: ,(.keySet {:a 1})

23:03 clojurebot: #< [:a]>

23:03 chessguy: hiredman, i see. i assume merge uses assoc

23:04 hiredman: ~def merge

23:04 durka42: it does not

23:04 chessguy: bummer

23:05 then wrapping assoc won't be enough

23:07 abrooks: chessguy: I have to ask... Is this really what you want to do?

23:07 chessguy: abrooks, good question

23:07 abrooks: :)

23:07 chessguy: the answer is, i'm not sure yet

23:07 i'm brainstorming for a problem i'll be facing down the road

23:07 good way to lwarn the language too :)

23:08 abrooks: A question I often wind up asking myself and more often with Clojure it seems. My first approaches are often orthogonal to the Clojure way at times.

23:08 chessguy: I also highly recommend ProjectEuler.net for learning languages, functional ones in particular. (It was a big help to me, at least.)

23:08 chessguy: bah

23:09 too much math knowledge needed

23:09 abrooks: chessguy: Heh. Okay.

23:09 chessguy: i don't really care to have to go look up fast prime-generation algorithms and such

23:09 at least, not while learning a language :)

23:12 anyway, learning the language isn't my primary goal at the moment, it's a side effect

23:13 ,(dissoc)

23:13 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: core$dissoc

23:14 chessguy: ,(dissoc {:a 1})

23:14 clojurebot: {:a 1}

Logging service provided by n01se.net