#clojure logs

2008-06-26

03:34Lau_of_DKMorning gents, straight to business: I need to make a JComboBox. and init it with some values. They need to be passed as a cstor argument in the form of Object(), how do I make that Object from Clojure?
03:46cgrand(to-array [arg1 arg2 argN])
03:58Lau_of_DKthanks cgrand
04:03cgrandyw
04:05arbschtcgrand: hi, I'm curious: how did you locate my blog post with the mini snake implementation? :)
04:06Lau_of_DKmini snake? gimme link =)=
04:07arbschtLau_of_DK: it's not that interesting http://www.plt1.com/1070/even-smaller-snake/
04:07cgrandarbscht: google alert on clojure
04:08arbschtcgrand: ah
04:09Lau_of_DKimpressively small
04:11Lau_of_DKIm having some syntax trouble. I did (def globs (ref hash-map)) for my globals, now when I want to commit a value, how do I get about it? I start firing casting errors with something like (alter globs (assoc :mykey "myval)) or in a transaction I get an invocattiontargetexception
04:13cgrandarbscht: submitted to reddit http://www.reddit.com/info/6p1ku/comments/
04:13cgrandBtw you could flatten "collision?" by removing two of the three "and"
04:15cgrandlau_of_dk: no need for that many parens :-) just use (alter globs assoc :mykey "myval) in a transaction
04:16arbschtcgrand: hm yes, thanks
04:17Lau_of_DKclever man... but cgrand that fires an "hash_map cannot be cast to Associative"
04:19cgrandwhat does hash-map contains?
04:19Lau_of_DKnothing yet, but its supposed to contain all my global-vars
04:19Lau_of_DKso that I reference all the globs to it, and extract the values
04:20cgrandI mean: an instance of java.util.HashMap or a clojure map?
04:21Lau_of_DK(def globs (ref hash-map))
04:21Lau_of_DKI suppose/hope that its a clojure-map
04:22cgrandeureka: what you wanted to write is (def globs (ref {})) or (def globs (ref (hash-map)))
04:25cgrandlau_of_dk: does it work now?
04:25Lau_of_DKhang on
04:26Lau_of_DKahem
04:26Lau_of_DKexplain it to the slow student please
04:26Lau_of_DKwhy does (hash-map) make the difference?
04:27cgrand(ref hash-map) creates a reference to the function hash-map
04:27Lau_of_DKIts a bit fuzzy to me, why does (alter bla bla assoc) work? I would image that (assoc) belong in () to evaluate it
04:27cgrand(ref (hash-map)) creates a ref to the result of evaluating (hash-map), ie the empty hashmap
04:32Lau_of_DKI understand that, but in relation to what you said about (alter ... asoc) compared to (alter ... (assoc..)) its not wholly clear to me
04:34cgrandalter, commute and send are functions not macros. So when you put parens around (assoc :mykey "myval") what is inside must be valid so as to be evaluated prior to the function (eg alert) call; here the map upon which you operate is missing so the content of (assoc :mykey "myval") must be break into pieces and passed directly to alter which will pu them all together with the current value of the ref
04:35cgrandbreak -> broken
04:40cgrandMore succintly: to write (alter globs (assoc :mykey "myval)) alter has to be macro since (assoc :mykey "myval) is inomplete.
04:42cgrandinomplete -> incomplete
04:51Lau_of_DKok cgrand, very good explanation, thanks alot
08:55Lau_of_DKHey blackdog
08:55blackdoghi
09:28rhickeycgrand: *agent* type hint in place
09:30rhickeycemerick: added *file*, but does not use URL path, because same path is put in debug info, where jar stuff breaks debuggers
09:33cgrandrhickey: thanks!
09:37cgrandrhickey: have you seen the bug reported by wwmorgan yesterday? (sorted-set) returns an empty hashmap
09:38cemerickrhickey: Thanks :-) Too bad about *file* not always being absolute, though.
09:38blackdogcemerick, what is *file*
09:38rhickeycemerick: begs the question of what is absolute when it's in a jar
09:39rhickeycgrand: just looking now
09:39cemerickblackdog: path to the clj file being loaded (via load-file, etc)
09:39blackdogok, thx
09:47cemerickrhickey: Sure -- FWIW though, file:clojure.jar!boot.clj is an absolute path, as interpreted by java.net.URL. I can certainly understand that allowing URL paths into bytecode as opposed to file paths could muck things up.
09:51Lau_of_DKAny of you guys know of an optimal way to approach XML handling in Clojure?
09:52blackdogthere's an xml.clj
09:52blackdogbut i haven't looked
09:52Lau_of_DKk thanks, sounds like a good place to start :)
09:52blackdogcheck api page for more
09:53Lau_of_DKoh goodie, Chouser has already posted some stuff on it :)
09:56blackdoganyone using jnlp with clojure?
09:56blackdogi never used it before, do i have to have a main-class tag in the descriptor when user.clj is run auto?
09:57Lau_of_DK(xml/parse "wayport.xml")
09:58Lau_of_DKlol - its a shame when your IRC client looks to similar to your REPL that you make those kinds of mistakes :)
10:13Lau_of_DKAm I remembering incorrectly, or was there a "loop across" functionality, that worked on hash-maps?
10:16rhickeycemerick: is there utility to such paths? what can you do with file:clojure.jar!boot.clj?
10:24cemerickrhickey: those paths aren't helpful to me, but a java debugger should have no problem yanking that resource if it's referenced in some bytecode (since remote code loading is ostensibly baked into java). The path that *is* helpful to me is an absolute path to user.clj, which would then be able to use *file* to know where it is and therefore the clojure it bootstraps from there would be able to reliably know what "root" to operate under. Right now, I'm ju
10:25cemerickI've been harping on the absolute path bit because the scenario I just described seems like it'd be a pretty common approach. *shrug*
10:26rhickeycemerick: you got cut off at Right now ...
10:26cemerickhuh... Right now, I'm just making sure my pwd is set properly; that will get replaced by some system property at startup that user.clj will pick up.
10:27blackdogcemerick, you could just start the jvm up in the correct root to start with, and know where you are? then use "user.dir" within the prog
10:28cemerickblackdog: Yeah, that's what I'm doing now.
10:31cemerickThere are definitely advantages to making environment concepts like "app root" and such localized to the code, rather than adding another requirement to the runtime configuration. That's definitely used a lot in the python world (for example), which has __file__, which is always the path of a file relative to your pwd.
10:32rhickeyhow is that not a classpath?
10:32cemerickrhickey: because when you load user.clj, *file* is _always_ "user.clj". It could be loading it from any of the root classpath entries.
10:33cemerickIn the python example, you can always get your absolute path with os.path.join(pwd, __file__)
10:34rhickeyDoes Pythonm handle remore code loading etc?
10:34rhickeyremote
10:35rhickeypwd doesn't seem a very useful concept once you get into remote code, app servers etc
10:36rhickeyI understand classpath has its faults
10:36cemerickaside from some hackish workarounds, not to my knowledge
10:36cemerickFWIW, I'm definitely not trying to do any direct comparisons, etc. The current situation is fine, just a little inconsistent between *file* in a load-file call and *file* when user.clj is autoloaded.
10:36rhickeyI think a current problem is Clojure doesn't use enough of the namespace management, i.e. those clj's shouldn't be in the root
10:37rhickeycemerick: yes, I understand
10:37blackdogon executing clojure from a jar file, should i include a main java stub class?
10:38blackdogit seems forced by the manifest
10:39blackdogor do i use a clojure main function somewhere to start things off?
10:39rhickeyto get a stand-alone looking solution (i.e. no supplied script), you could, although the user.clj autoloading helps avoid that too. Note that gen-class can generate main now
10:40blackdogright now i'm trying java -cp clojure.jar app.jar with user.jar in app.jar and a stub java main
10:41blackdogi maean user.clj
10:41blackdogbut user.clj is not (println "hello")
10:41blackdognot unless it's a flush thing
10:41cemerickrhickey: BTW, I hacked together a little macro that loads and then saves a generated class in order to get around the self-referential problem mentioned yesterday. Definitely not a long-term solution, but it gets the job done (for now, and probably only for me :-) ).
10:41blackdogshould that work?
10:45rhickeycemerick: ok, sorry I hadn't thought of that self--reference in the first cut
10:46cemerickrhickey: seriously, no need to apologize
10:47Lau_of_DKnaah man, we all make mistakes :)
10:52Chouser_blackdog: I have gotten into the habit of always putting (flush) after any prn or println used for debugging. It makes things less surprising.
10:52Chouser_I dunno if it'll help in your specific case, though. :-)
10:59cemerickChouser_: damn, I had always thought that println did a flush itself.
11:00rhickeyyeah, that seems to be a frequent trip-up for people, I'm considering changing it
11:00Chouser_oh. well, I usually use (prn) for debugging. I'm not sure what println does.
11:01Chouser_...so I'm back from my trip. Have we seen a flood of new users from the 8 people I talked to on Friday? No? Ah, well... ;-)
11:02rhickeydid you have door prizes?
11:03Chouser_I guess I should have had a whole box of clojure T-shirts or something.
11:03Chouser_Oh. Man. We should have Clojure T-shirts.
11:03rhickeythere you go
11:03rhickeyI have one
11:03YcrosI would buy one
11:04Chouser_does it have a snappy quip?
11:04rhickeyfrom my wife - it says "You're doing it wrong" on the back
11:04Chouser_There you go!
11:04Chouser_really, that's perfect. You would sell a dozen, at least.
11:07rhickeywmorgan: (sorted-set) fixed
11:09cemerick"You're doing it wrong" sounds good, although I'm currently feeling a little allergic to that sort of confidence, after watching a couple of noobs get torched in #lisp yesterday.
11:10Chouser_yeah, it's not clear that we mean anyone *not* using Clojure. Everyone using clojure is, of course, doing it Right.
11:10rhickeyI prefer - "State - you're doing it wrong", about which I am more confident
11:11rhickeybut, as I said, it was a gift. Clojure is generally non-confrontational
11:11cemerickSure. I'm just feeling punchy today. ;-)
11:12Chouser_Maybe just flip it around to positive: "you can do better"
11:16Chouser_"Who knew Java could be so fun?"
11:26cemerickI'm just waiting for the Clojure lolcats to start making the rounds.
11:27rhickeylolcats?
11:28drewr"Java: Makes better languages than applications."
11:29cemerickrhickey: here's some haskell-themed ones: http://arcanux.org/lambdacats.html
11:29rhickeyah
11:43rsynnott_heheh
12:12Chouser_http://www.zazzle.com/state_you_re_doing_it_wrong_shirt-235609552304110841
12:12Chouser_I of course haven't bought one yet, so I have no idea what the quality is like.
12:13Chouser_...and I'm happy to hand the password and stuff to rhickey so he can collect the proceeds if anyone buys any.
12:34abrooksChouser_: No Clojure logo?
12:34Chouser_on the front.
12:35Chouser_want another on the back? i guess it might spice it up a little.
12:35rhickeychouser: cool!
12:36albinodo you get to choose the font for that?
12:36Chouser_yes
12:36Chouser_I think you can customize your shirt however you want, from that link.
12:37albinoI would so wear that shirt to some geek conference
12:38Chouser_Since I'm using C++ at work, maybe I need one for the office that says "State - we're doing it wrong"
12:38albinoheh
12:38albinogive it to the managers and see if you can get them to wear it to meetings
12:42Chouser_abrooks: with a logo on the back: http://www.zazzle.com/state_you_re_doing_it_wrong_shirt-235415785053901854
12:45rhickeyChouser: do you need bigger images? I have 500x500 and can get larger
12:45Chouser_nope, thanks. That's about 500x500 already.
12:46Chouser_I've got an SVG now that seems accurate enough for whatever.
12:47Chouser_I assume 500x500 is enough for that size on a T-shirt. Whoever buys the first one can report on that.
12:47rhickeytomhickey: any thoughts on SVG?
12:53Chouser_or in black: http://www.zazzle.com/state_you_re_doing_it_wrong_black_shirt-235357523415203587
12:53Chouser_ok, that's enough. you can pick one of those or go customize it yourself.
13:02pjb3http://farm4.static.flickr.com/3229/2613013337_ecc41f4123_o.jpg
13:03tomhickey_http://groups.google.com/group/clojure/web/Clojure.svg
13:05drewrpjb3: Hahaha.
13:08Chouser_pjb3: nice
13:09Chouser_tomhickey_: thanks!!
13:09Chouser_I should have asked for that last week instead of tracing my own.
13:22tomhickey_Chouser_: no problem. glad i could help
13:33rapidoi wonder if clojure has any distributed computation/data capabilities ?
13:34rhickeyrapido: not yet
13:34Chouser_aren't there several Java libs that can make that happen?
13:34rapidorhickey: i guessed that you are thinking about it. care to share some thoughts?
13:35rapidoi believe immutability scales very well in a distributed environment
13:35rapidono more stale caches
13:36blackdogin rhickey's concurrency talk he mentions the possibility of wrapping jms
13:36NafaiHi rapido!
13:36rapidohey nafai - the user list shows some more concatenative :)
13:37rhickeythere are many aspects, first is some sort of process coordination/communication, for which I am looking at Shoal
13:37rhickeythen there's distributed data/computation
13:38rhickeyI'd definitely prefer to sit on some well-regarded Java infrastructure
13:38rhickeynot interested in writing my own distributed DB
13:39rapidorhickey: i believe you only need to implement a distributed hash table
13:39rapidoon that, you can build any data structure
13:40rapidofor instance, you can overlay an immutable data structure on top of a dht
13:40rhickeywe've discussed that here, but a distributed hash table is a big project
13:40cemerickFWIW, I'm leaning towards hadoop and HBase for our current project
13:41cemerickThere's already a reasonably-pleasant hadoop wrapper for clojure on the google group. The data models are nicely congruent.
13:41rapidothere are many dht's: azureus, limewire, overlayweaver, freepastry, all of them on the jvm
13:41Lau_of_DKEvening gents
13:44abrooksrhickey: As I work for an HPC company (http://SiCortex.com) I've been thinking about Clojure's concurrency mechanisms and how they might be extended across multiple nodes. It seems like the general idea behind persistent data structures could be extended but lazy fetching would lead to unacceptable latencies and there are issues of distributed GC (not unsurmountable but issues none the less). The current concurrency ...
13:44abrooks... mechanisms operate on non-NUMA assumptions -- everything costs the same.
13:44rapidobuilding an immutable data structure on a faulty (but redundant) dht can give you ACID properties
13:45rapidousing some kind of MVCC or other conflict resolution methods
13:46rapidorhickey: so there is no need to build a distributed db yourself. just leverage on top a dht
13:46rhickeyabrooks: It is fundamental to Clojure's model that the distributed and local models not be unified, so I expect something different will be needed for the distributed case
13:47rapidorhickey: i agree you can't/shouldn;t hide distance/network/etc.
13:48rapidolike you can't hide multiple cores
13:48rapidobehind leaky abstractions
13:49rapidobut how should they be exposed first class?
13:50rapidothrowing an network-exception isn't the way forward
13:50rapidonor hitting a stale cache entry
13:51rhickeyI think Erlang's distributed model can't be ignored
13:51rhickeybut it is hard
13:52rapidorhickey: agreed, but erlang isn't exactly p2p
13:52rhickeyi.e. it just acknowledges that distributed programming is fundamentally hard
13:53rapidop2p must handle faulty nodes, faulty networks, churn, byzantine problems, etc.
13:54rapidoyou shouldn't trust no one in p2p networks! tit for tat i say :)
13:55rapidorhickey: distributed programming IS hard, yes. erlang has a lot of right defaults
14:01abrooksrhickey: Right, I wasn't suggesting that the difference between fastl/local / slow/distributed be hidden but more wondering how you saw slow/distributed fitting in with the current scheme. I could see some rich proxies of refs/agents and a mechanism proxied references for distributed GC purposes being somewhat natural fits with what we have today. One thing that shouldn't be hidden is some for of eager (or limited ...
14:01abrooks... eager) caching of data in the reference proxying.
14:02rhickeyAll this is still preliminary, but here are some things I've been thinking about:
14:03rhickeyErlang-like procs based upon Shoal
14:03rhickeydistributed agents also based upon Shoal
14:03rhickeyDistributed STM based upon Terracotta
14:04abrooksBTW, I'm sitting in USENIX talks right now and every talk is mostly centered around the issue of "How dow we make use of multiple cores? How do we scale software in a comprehensible manner?" I keep wanting to shout out "Clojure!"
14:04rhickeyI think Terracotta could do a good job with the data structures, but the synchronization primitives were too slow last time I tried it
14:05rapidoshoal is more like erlang, less like p2p
14:06rapidotrusted nodes
14:06rapidoinstead of faulty peers
14:06rhickeyI had an earlier version of the Clojure STM running on Terracotta at one point
14:06rapidoor malicious peers
14:14drewrabrooks: Ah, you're listening to Pratt in *person* :-)
14:15cemerickI'm still somewhat unclear about the use case for jvm-level clustering like Terracotta. "Transparent" distributed concurrency comes with so many potholes and (from what I've read) very little about data management.
14:16cemerickThat's all probably a function of my problem space though. :-)
14:17rhickeyit's true that once you go distributed, there is no 'one size fits all'
14:18rhickeysome problems are mostly autonomous processes that need to communicate
14:18rhickeysome are distributed crunching, a la map/reduce
14:18rhickeysome are shared database
14:25abrooksdrewr: ;-) The Pratt talk is over now.
14:41cemerickI suppose terracotta or shoal would help in building a durable message queue...
14:41cemerickit's very hard to thing outside of one's particular box when you're deep in it :-)
14:42rhickeyyes, and there are independent solutions for all of those specifics, including message queues, so it does beg the 'what belongs in the language' quesiton
14:47Chouser_rhickey: You're probably not deep into XML, but any particular reason xml/parse isn't lazy?
14:47rhickeymaps aren't lazy
14:48Chouser_but the seq of children in each map could be
14:49cemerickrhickey: well, the huge mass of potential solutions to these problems jumping up and down, marketing themselves as the second coming makes me think that any *language-level* support is premature. Libraries are good when things are in flux.
14:49rhickeyChouser: with what parser?
14:50abrooksChouser_: You couldn't see well formedness with a lazy parser.
14:51Chouser_sax parsers work with incremental input
14:52rhickeyyes, but you are asking for delayed subtrees
14:54Chouser_you don't think it's possible with stock Java sax parsers?
14:54rhickeyI have no idea - you'd have to be able to checkpoint things as you passed them, as you'd have to read the subtrees anyway in order to skip them
14:55Chouser_yeah. But zip and zip-filter are already lazy in this way, where they can work with parts of the tree without ever examining other parts.
14:55Chouser_if the "other parts" were later in the file, it seems like it might work.
14:56rhickeynow if xml was a chunked data format...
14:56Chouser_anyway, just asking. Maybe I'll play with writing a drop-in replacement for xml/parse that's lazy.
14:56rhickeyzip is working with a real tree
14:57rhickeyxml files become trees, but they are not trees
14:58rhickeyChouser: it's a valid objective - I was just thinking about lazy-reading for Clojure this morning
14:59Chouser_I do think it'd be very easy to make a zip call (and even more so a zip-filter call) that required the whole doc to be parsed, without realizing you were requiring that.
15:22Chouser_ignore my earlier t-shirt links. Just use this one: http://www.zazzle.com/clojure
15:22Chouser_I'll shut up about them now. :-)
15:32Lau_of_DKWoot - How made that print?
15:32Lau_of_DKHow = Who
15:51Lau_of_DKnobody will claim responsebility? You'd make lousy terrorists
15:52Lau_of_DK(oops, I might have crashed an Echelon server)
15:54Chouser_Lau_of_DK: I think pjb3 made the poster, if that's what you're talking about.
15:55pjb3What, the automotivator? Yeah, that was me
15:59Lau_of_DKWhat is an automotivator?
16:00Chouser_Lau_of_DK: http://wigflip.com/automotivator/
16:02Lau_of_DKNice work pjb3, but because with harassing the Pope
16:03pjb3harassing the Pope? Are we talking about the same thing? http://farm4.static.flickr.com/3229/2613013337_ecc41f4123_o.jpg
16:03Lau_of_DKhaha, no I wouldnt go that far about Rich
16:04Lau_of_DKhttp://images.wigflip.com/funny.jpg
16:05Chouser_Lau_of_DK: I don't think that worked like you meant.
16:06Lau_of_DKChouser: What do you mean ?
16:06Chouser_You just posted a plain picture of the pope. Is that what you meant to do?
16:07rhickeyThe pope is OT for Clojure :)
16:07Lau_of_DKYes sir... My point was this, at the wigflip.com/automotivator page, the picture of the pope is suggested, and I was just saying that something like that usually sends sparks flying - thats all
17:22cemerickrhickey: Back to the gen-class stuff. Would it also be possible to provide the name of the class to be generated by gen-class as a symbol? Doing so would allow gen-class to be totally independent of the state of the runtime, which would eliminate the possibility of any cyclic dependencies between Java code and referenced gen-classed classes.
18:01rhickeycemerick: yes, that's how it will work when I get back to it
18:02cemerickrhickey: fantastic. That makes life a lot easier.
23:10Chouserbah. so the SAX parser expects a blocking reader. It won't return until the Reader is done.
23:10ChouserI think that means the only way to make it lazy is to pack it off into its own thread.