#clojure logs

2009-05-17

02:22Serkanhi
02:25stuhoodheya
02:27Serkanwhat's the version of asm bundled with clojure 1.0, and is it a modified copy?
02:29hiredman~def clojure.asm.ClassWriter
02:30stuhoodaccording to SVN, it hasn't been modified since Dec 2007
02:31hiredmanwhich is maybe around the time the switch to google code happened?
02:32danlarkin_2007?
02:32Serkanany maintainers arounmd?
02:33hiredmanoh
02:33hiredmanright 2007
02:35hiredmanSerkan: I am kind of curious, why are you asking about asm?
02:35stuhoodSerkan: 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
02:53Serkanhiredman: I'm a Gentoo trying to package clojure
02:53hiredmanand you want to split out clojure.asm.*?
02:53SerkanI'll use the system asm library if the bundled one isn't a modified version
02:54Serkanah the package structure is different as well :(
02:54hiredmanSerkan: as rhickey mentions in that google group posting, a lot of projects use asm, so to avoid conflicts
02:55hiredmanI would just grab the zip file, extract clojure.jar and forget about it
02:56Serkanhiredman, stuhood thanks for the pointers
02:56stuhoodno problem... glad to see Clojure making it into Gentoo
03:00Serkanthough I need to ask the others if they're OK with bundled asm.
03:05cads_are you going to bundle bash startup scripts and such?
03:07Serkancads_: ?
03:07Serkanwas that for me
03:07cads_yeah, I was just wondering about how clojure will be packaged in gentoo
03:08cads_I've been thinking about making a deb
03:08SerkanI'm making a luancher that runs clojure.lang.Repl
03:09danlarkin_Serkan: clojure.lang.Repl is old and busted, use clojure.main
03:09danlarkin_Serkan: check out http://code.google.com/p/clojure-contrib/source/browse/trunk/launchers/bash/clj-env-dir for a good example
03:14Serkandanlarkin_: I see. I guess I found this in homepage
03:19Serkandanlarkin_: fixed http://overlays.gentoo.org/proj/java/changeset/7762
03:20danlarkin_Serkan: cool :)
04:37unlinkBah. No UNIX sockets in Java?
04:37stuhoodthe api isn't identical, but you can use raw sockets
04:38unlinkWhat do you mean "raw"?
04:38unlinkAs in TCP/IP?
04:38stuhoodno, sorry, not sure what i meant
04:38stuhoodhttp://java.sun.com/javase/6/docs/api/java/net/Socket.html
04:38p_lraw sockets usually mean directly writing to device...
04:39unlinkYeah, those look like TCP/IP sockets.
04:40markusgustavssonI don't think java supports raw sockets
04:40stuhoodsorry... i didn't mean raw sockets.
04:45unlinkI'm looking for something along the lines of http://u.nu/5g46 ...surely some library exists
04:45Serkanunlink: libmatthew-java has
04:48unlinkThanks...hmm, it's missing from my repo
04:49Serkanunlink: http://www.matthew.ath.cx/projects/java/
04:50hiredmanyou could use chouser's jna lib
04:51unlinkNo wonder I couldn't find it. ath.cx
04:51hiredman"Dynamically load and use native C libs from Clojure using JNA"
04:51hiredmanhttp://github.com/Chouser/clojure-jna/tree/master
04:52unlinkWhat C library did you have in mind? libc?
04:53hiredmanyeah
04:53hiredmanopen()
04:55hiredmanwow
04:55hiredmanit has been a long time since I have written any C
04:56unlinkimport cx.ath.matthew.unix.UnixSocket; is mad sketchy
04:57hiredmanhow so?
04:57unlinkimport cx.ath. ...
04:57unlinkdyndns
04:58unlinkthough I actually intended that message for another tab
04:58hiredmanI had a .cx back in the day
04:59hiredmanah
08:31guineaI'm just wondering, is a zipper how the emacs buffer works?
08:32kotarakThe Yi buffers seem to work like a zipper. Dunno about emacs.
11:32Qvintvsdoes 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:32Qvintvsdoes clojure*
11:33dreishYou could do (System/exit 0)
11:35Qvintvsyay, ty
12:06Chouserunlink: I'd actually recommed using jna on libc curerntly, over that libmatthew thing.
12:08p_lChouser: it might even work on Windows, I think :)
12:08ChouserI'm pretty sure Windows doesn't have unix domain sockets.
12:11p_lit's just non-standard optional package
12:11Chouserhuh
12:11p_ljust like there's a setting that changes the whole system into case-sensitive, including devfs (which can break various code)
12:13p_loh, and the MS installer of SUA (Services for Unix Applications) includes GCC
12:56markusgustavssonSo what's the jna performance like? Same as regular jni?
13:19grosoursplop
13:42Chousermarkusgustavsson: https://jna.dev.java.net/#performance
13:48Chouserso, no, not as fast as jni. :-)
13:58guineaIs 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:00Chouserproxy takes a class and returns an instance.
14:00guineahmm
14:01ChouserI guess I'm not sure what you're trying to do. A proxy can't add methods...
14:01guineai'll have to write a macro to combine overloadings into a proxy statement...
14:02guineaI've written different proxies, to overload a java class in various ways
14:02guineaand I want to be able to create proxies that have combinations of those
14:02Chouserif 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:02guineacool
14:02Chousereach 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:02guineawhere do I find the macro source?
14:03Chousermaybe not even need to write a macro
14:03Chouser~def proxy
14:03Chouseror (source proxy) if you have clojure.contrib.repl-utils
14:03guineasweet
14:04Chousergotta go mow. ciao.
14:04guineathx
15:25quidnuncAnyone at all familiar with enlive?
15:26dnolenyes
15:35quidnuncdnolen: If I want to select a table node with class "bar" shouldn't [:table (attr= :class "bar")] work?
15:36quidnunc[:table (attr? :class)] seems to return more results than just [:table}
15:37dnolenisn't there a has-class?
15:38dnolenquidnunc really it should be
15:38dnolen[:table.bar]
15:39dnolen[:table (attr? :class)] will return any table that has a class attribute not just bar.
15:39quidnuncdnolen: It does a union?
15:39dnolenno it's how CSS3 works
15:39dnolentable.bar matches a table with class bar
15:40dnolen[:table.bar] is the enlive translation.
15:40quidnuncdnolen: I meant [:table (attr? :class)]
15:40quidnuncThat does a union?
15:40dnolenI suppose so, but it simply means "return all tables that have a class attribute"
15:42quidnuncBy union I meant table OR class attribute. Shouldn't this work: [:table (attr= :class "bar")]
15:42dnolen?
15:42dnolenyou want all tables or anything with a class attribute?
15:42quidnuncI want table with class attribute "bar baz"
15:42quidnunctables*
15:43dnolen[:table (has-class "bar baz")] should work I think.
15:46lisppaste8quidnunc pasted "enlive class selector" at http://paste.lisp.org/display/80388
15:46quidnuncdnolen: ^ It doesn't seem to
15:47dnolenoops
15:47dnolenthe docs say
15:48dnolen[:table.bar.baz]
15:49quidnuncdnolen: Ah, good. Works now.
15:49quidnuncdnolen: Thanks. That was driving me a bit up the wall.
15:49dnolennp
15:50quidnuncThat seems a bit nasty though. How do you deal with dynamic class names?
15:51quidnunc(has-class "bar" "baz") doesn't seem to work.
15:52quidnunc(and splitting the args into separate strings every time is unpleasant)
15:53quidnuncActually, I'm surprised that what I initially tried didn't work. Shouldn't class be treated like any other attribute?
15:59danlarkin_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:59mcspiffanyone feel up to helping a newbie get slime setup?:D
16:01quidnuncdanlarkin_: So their is no distinction in enlive between class="foo bar" and class="foo" class="bar"?
16:01quidnuncthere*
16:04danlarkin_quidnunc: in enlive? I don't know, there probably is. I'm just saying why it's the way it is
16:05quidnuncdanlarkin_: Okay, thanks.
16:11mattikusIs there a decent way to catch ctrl-c from the repl and have it not exit?
16:27liebkemattikus: 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:28mattikusShucks. 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:32fyuryuStartsWithK: Hi
16:33liebkeyeah, 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:35fyuryuStartsWithK: 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:58StartsWithKfyuryu: oh, hi, i wasn't here
16:59StartsWithKfyuryu: 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:59StartsWithKfyuryu: also imported some of your code from your libs project, i think is down to graph and utils now
17:00StartsWithKfyuryu: also removed test-is and replaced it with my fork of clj-unit so test can be peformed with build
17:00StartsWithKfyuryu: and replaced some of your code with stuff from commons-io, like mkdir and such
17:00StartsWithKnow i have a problem, i did it i know, tests fail
17:00StartsWithKbut i think i can fix that tomorow
17:01fyuryuStartsWithK: ah, I somehow missed that github clone
17:02StartsWithKso next step would be ant task for compiling clojure sources in a way javac does it
17:03StartsWithKi have such a task for ant but it is in javascript, and i was planing to port it to pure clojure
17:03StartsWithKso i can use read with eval = false to realy check for namespace names
17:03StartsWithKi would like to place that code in cloak instead of my project
17:04StartsWithKand 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:05StartsWithKwill you accept that patches too?
17:06fyuryuStartsWithK: <StartsWithK> so i can use read with eval = false to realy check for namespace
17:06fyuryu names --- not sure I understand that part
17:08StartsWithKfyuryu: http://paste.pocoo.org/show/117753/
17:08StartsWithKfyuryu: 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:09StartsWithKit dosn't work if you type ;(ns blah..)
17:09StartsWithKanyway that task works like <clojurec srcdir='' destdir=''/> so you don't need to write namespaces you would like to compile
17:10fyuryuStartsWithK: Ah, I get it now
17:11StartsWithKfyuryu: 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:12fyuryuStartsWithK: 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:14StartsWithKfyuryu: 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:14StartsWithKi 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:14djkthxwhats the equivalent to member in clojure?
17:14djkthxfrom common lisp?
17:15fyuryuStartsWithK: I found your repo on github, I'll try to find time during the week/weekend to look at it
17:16StartsWithKfyuryu: thanks, just don't merge, its not functional for now.. well i guess i could go now and try to fix it :)
17:19fyuryuStartsWithK: ok
17:22danlarkin_Chouser: did you see my post in the error-kit + test-is thread? Any thoughts?
17:47dfdeshomhi, is there a way to build objects in clojure? something like the clos comes to mind
17:48opqdonutproxy
17:49opqdonuthttp://clojure.org/java_interop#toc25
17:49dreishThere's nothing like CLOS. The usual thing is to use hashes and multimethods.
17:50opqdonutyeh
17:53dfdeshomcan I define custom operators for my types? Eg for ^,&, etc
17:58danlarkin_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:00StartsWithKdfdeshom: you could also take a look at clojure.contrib.generic library
18:01dfdeshomthanks guys.
18:02dfdeshomI'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:03dreishScala and Clojure are extremely different languages.
18:08dfdeshomthat'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:36StartsWithKdfdeshom: 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:05dfdeshomStartsWithK: 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:58bpattisoncan anyone tell me what the last statement is false?
19:58bpattisonuser=> (= () '())
19:58bpattisontrue
19:58bpattisonuser=> (= {:x ()} {:x '()})
19:58bpattisontrue
19:58bpattisonuser=> (= {:x '({:y ()})} {:x '({:y '()})} )
19:58bpattisonfalse
19:58bpattisonit seems like it should be true as well
20:00rhickey(:y '{:y '()})
20:00rhickey,(:y '{:y '()})
20:00clojurebot(quote ())
20:00rhickey(:y '{:y ()})
20:00rhickey,(:y '{:y '()})
20:00clojurebot(quote ())
20:01rhickey,(:y '{:y ()})
20:01clojurebot()
20:01rhickeythe outer quote prevent the inner one from being evaluated
20:01rhickeyprevents
20:02bpattisonoh -- so the outer quote is applying to the rest of the statement -- okay thanks
20:02bpattisonand I don't need to quote the inner one
20:03rhickeybpattison: right
20:04rhickey'() is always unnecessary, just use ()
20:04bpattisonokay, that really helps me understand what's going on --thanks
22:49chessguyare merge and merge-with about the only way to combine 2 maps?
22:53abrookschessguy: You can also conj two maps with the latter taking precedence: (conj {:a 1 :c 3 :b 42} {:b 2 :d 4})
22:53abrooks,(conj {:a 1 :c 3 :b 42} {:b 2 :d 4})
22:53clojurebot{:d 4, :a 1, :c 3, :b 2}
22:55chessguyhmm
22:57abrooksIn fact, I'm having trouble thinking how merge is any different than conj without going and looking at core.clj.
22:57chessguyso there's no good way to conj the two together, applying some uniquifying function to any key that's a duplicate
22:58abrookschessguy: That's what merge-with is for.
22:58chessguyno, i want both the original key and a uniqified version to be in the result
22:58abrookschessguy: The function you specify allows you to handle the duplicats.
22:59abrookschessguy: Under the same key? You can't, the key must be unique in the map.
22:59abrookschessguy: You can merge the values and that's what it does.
22:59chessguysorry, i'm clearly not making myself clear
23:00chessguyi want something like (my-merge uniquifier {:a 1} {:a 1}) => {:a 1 :a_ 1}
23:00hiredmanchessguy: sounds like you want to wrap assoc
23:00unlinkMan, I'm so glad I found repl-utils/javadoc ... I was about to write that
23:00hiredmanor wrap merge
23:00chessguywhere uniquifier figures out how to generate the new symbol
23:01chessguyhiredman, hm. maybe wrap merge to be able to add a sequence of symbols to the resulting map?
23:02hiredman,(assoc {:a 1} :a 1 :b 2)
23:02clojurebot{:b 2, :a 1}
23:03hiredmanso you just wrap assoc to generate uniquefied keys for keys already in the keyset
23:03hiredman,(.keySet #{:a})
23:03clojurebotjava.lang.IllegalArgumentException: No matching field found: keySet for class clojure.lang.PersistentHashSet
23:03hiredman,(.keySet {:a 1})
23:03clojurebot#< [:a]>
23:03chessguyhiredman, i see. i assume merge uses assoc
23:04hiredman~def merge
23:04durka42it does not
23:04chessguybummer
23:05chessguythen wrapping assoc won't be enough
23:07abrookschessguy: I have to ask... Is this really what you want to do?
23:07chessguyabrooks, good question
23:07abrooks:)
23:07chessguythe answer is, i'm not sure yet
23:07chessguyi'm brainstorming for a problem i'll be facing down the road
23:07chessguygood way to lwarn the language too :)
23:08abrooksA 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:08abrookschessguy: I also highly recommend ProjectEuler.net for learning languages, functional ones in particular. (It was a big help to me, at least.)
23:08chessguybah
23:09chessguytoo much math knowledge needed
23:09abrookschessguy: Heh. Okay.
23:09chessguyi don't really care to have to go look up fast prime-generation algorithms and such
23:09chessguyat least, not while learning a language :)
23:12chessguyanyway, learning the language isn't my primary goal at the moment, it's a side effect
23:13chessguy,(dissoc)
23:13clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: core$dissoc
23:14chessguy,(dissoc {:a 1})
23:14clojurebot{:a 1}