#clojure logs

2009-08-08

02:30tomojis there a way to check if a var is bound?
02:31hiredmanclojurebot: vars?
02:31clojurebotExcuse me?
02:32hiredmanI would checkout http://clojure.org/vars
02:32tomojreading that
02:33hiredmanvars do have an isBound method
02:34hiredman,(.isBound #'+)
02:34clojurebottrue
02:34hiredmanI think you have to try pretty hard to get a hold of a unbound var
02:35tomojholding cookies from login in a var, but if the user hasn't logged in yet, that var is unbound
02:35tomojguess I can just put {} in the root binding
02:35hiredmanuh
02:35hiredmanseems like a ref or an atom would surely be a better idea
02:36tomojguess I'm thinking in CL
02:36tomojI'll reread the sections about those
02:38hiredmananything where you are rebinding the root value of a var is not good
02:39tomojan atom looks good
03:47thermalnoisewhat is the best way to create an enumeration in clojure? should i define some values in their own ns?
03:48tomojwhat's the difference between an enumeration and a set?
03:49thermalnoiseas the docs put it, "a set is a collection of unique values". so there could be more than one value in a set, if i got that right
03:49tomojdon't enumerations have more than one value?
03:50thermalnoiseyes, but only one is "toggled"
03:50hiredman
03:50tomojguess I'm not sure how you would use this "enumeration" thing in clojure
03:50hiredmanjust use keywords
03:51thermalnoisewill read about that. i am new to clojure (coming from the c side)
03:52tomojyou don't have to worry about type so much in clojure
03:52tomojso no need to make new enumeration types
03:52hiredmanI think enums in a dynamic language are pretty silly
03:54thermalnoise@hiredman: care to explain why?
03:56hiredmanthermalnoise: enums seem to be an artifact of type systems
03:57hiredmanyou create an enum type that holds one of x defined values and your function returns that enum
04:00thermalnoisejust to clarify, how would you track the state of an object in a persistent storage without using enums? like, experiment x is "in preparation"/"running"/"finished"?
04:01hiredmanjust use keywords, as I said
04:01hiredman:in-prerp :running :finished
04:01hiredmanhttp://clojure.org/data_structures#toc8
04:01mikehincheyif your object is a map {:state :running, :data x}
04:01thermalnoiseread that moments ago, thanks :)
04:02mikehincheyyou might have an enum #{:running :finished :in-prep}
04:02hiredmanmikehinchey: but why?
04:02mikehincheyto validate the value of :state
04:02tomojtrust vs. flexibility I suppose
04:02mikehincheydocumentation
04:03hiredmandocs go in the docstring
04:04mikehincheyit depends on how complex it is, I might want to write code around it, give nice error messages, make assertions
04:04hiredman*shrug*
04:05mikehincheyok :), just thought I'd answer his question
04:05hiredmansure sure
04:08thermalnoise@hiredman: just tried keywords and had my d'oh moment for today. thanks for your help.
04:12jwhitlarkwhat's the clojure equivalent of python's dir?
04:13jwhitlarkto show all members of a java object.
04:14jwhitlarklooks like show from repl-utils
04:16tomojjwhitlark: nice, I had wondered that myself before
04:18jwhitlarkI'm trying to get dbus going. not so fun. first the package in ubuntu was broken, now I'm playing with the interface...
04:18iBongdoes slime/swank have a built in command to call javadocs in clojure mode?
04:19jwhitlarkhiredman: oh, incidentally, your name came up at the BA-clojure meeting last night for always helping people out. It's appreciated.
04:22tomojiBong: I don't think so
04:22tomojiBong: http://bc.tech.coop/blog/081120.html and http://cynojure.posterous.com/clojure-emacs-and-javadocs look interesting
04:26jwhitlarkhmmm. Has anyone had any luck with dbus from clojure?
04:36jwhitlarkThe new emacs interface to dbus in 23 is certainly cool.
04:42tomojthat looks really cool indeed
04:42tomojwhen I move from os x to stumpwm that'll certainly come in handy
05:18tomojis there something prettier than (take-while identity coll) ?
07:31fsmHello everyone.
07:31fsmI have uploaded my ray tracer source code to http://cray.googlecode.com/ for anyone who is interested.
08:42slaneynewb q...how can I repeat a string as part of a larger string?
08:42slaneylike in ruby I might have something like 4.times{print "x"}
08:51slaneyI realize that's not really functional, but I was hoping to create a string, that a character repeated a number of times in the middle
08:51slaney*had
08:58Chousuke,(apply str (take 4 (repeat "test")))
08:58clojurebot"testtesttesttest"
08:58Chousukeslaney: ^^
08:58Neronusslaney: (reduce str (repeat 4 "x"))
08:58slaneyoh man
08:58slaneyheh
08:58Chousukeapply str is better.
08:58slaneyapply
08:58slaneyI forgot that one
08:58slaneytyvm
08:58Chousukeuses a single stringbuilder.
08:59slaneyI am not kidding, I tried for like an hour last night and an hour this morning to come up with something
08:59slaneyhehe
08:59slaneythanks
09:00NeronusChousuke: I confused that with some argument list length limit; you're right of course
09:34rhickeyreplaca: ping
10:00duck11231Are there any clojure libraries for emitting ns-aware xml yet? It seems that c.c.lazy-xml doesn't deal with namespaces. Are people just using the java xml libs for that?
10:47tomojhmm
10:48tomoj`(range (first vec) (second vec) step)`. better way?
10:50tomoj(eval `(range ~@vec step)) :(
11:04leafwany reason why http://clojure.org/api#toc398 exists at all? Looks like a bug in the API generator.
11:05leafwthere are many more such "Macro" API links listed.
11:41tomojgrr
11:41tomojclojure.core/empty is evil
11:58leafw(doc empty)
11:58clojurebot"([coll]); Returns an empty collection of the same category as coll, or nil"
12:41LauJensenTop of the evening guys :) Anybody tried that flu thats going around? Its awesome
13:45LauJensenWhen Rich talks about atoms being synchroneous and refs/vars being a-sync, how much should I read into that? For instance, what are the implications of synchronious datatypes?
13:55hiredmanLauJensen: where did you hear that?
13:56LauJensenclojure.org/atoms
13:57hiredmanand about refs being async
13:57hiredman?
13:57LauJensen3.rd paragraph "for which you wish to make synchronous changes (unlike agents, which are similarly independent but asynchronous)."
13:58hiredman(still don't see refs)
13:58hiredmanagents are deinitely async
13:58LauJensenoh yes youre right
13:58LauJensenQuestion remains though
13:59hiredmanessentially async means operations happen on another thread
14:00hiredmanhttp://clojure.googlegroups.com/web/clojure-conc.png
14:02tomojcoordinated means "in a transaction" essentially?
14:03hiredmantransactions are the reason refs are coordinated
14:04LauJensenok
14:04hiredmanit means if you do an operation where you mutate two atoms you have the potential for a race condition because there is no way to coordinate the change between the two atoms
14:08rlbIf you have a network socket connected to a device that will periodically send updates, and to which you'll periodically send commands (that have no direct responses), what would be a reasonable approach?
14:08rlbPerhaps an agent representing the device's state, with a thread for the incoming data, and another agent for the outgoing commands (to serialize mutiple senders)?
14:09hiredmansounds reasonable
14:10rlbok, thanks.
14:29LauJensenhiredman: So the difference in use-cases for refs and atoms, is basically the coordination? Wether you need it or not
14:33hiredmanyeah
14:34LauJensenGreat
14:52MarkVolkmannAs far as I can tell, the abort method in LockingTransaction.java isn't currently used. Maybe it's there for possible future use. Is that correct?
15:08duck11231If I have a multimethod that dispatches on a vector with two values, is there any way to write a default handler that matches one of the values, but leaves the other unbound?
15:09kotarakduck11231: for Java objects (derive Object ::YourGenericName), but for keywords each has to be derived manually.
15:10duck11231now that I think about it, it might be best to have the default handler call out to another multimethod that dispatches on just the one value
15:10kotarakAlso possible
16:08broolare there any good references for trying to optimize tight inner loops in Clojure? I have some array manipulation in a tight loop and it looks like aget / aset-int / whatnot are getting boxed and unboxed all over the place.
16:10kotarakbrool: type hints, here is a nice example: http://clj-me.blogspot.com/2009/08/what-warn-on-reflection-didnt-tell-you.html
16:10kotarakOtherwise, stress google a little. There was lot of discussion about this and lots of good tips.
16:12broolkotarak: thanks, i will look at that. i have googled quite a bit, but even with type hinting it looks like there is boxing/unboxing going on
16:12hiredmanhttp://clojure.org/java_interop#toc36
16:12hiredmanhttp://clojure.org/java_interop#toc46
16:33Fossi1lisppaste8: url
16:33lisppaste8To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.
16:34lisppaste8Fossi pasted "macro and params" at http://paste.lisp.org/display/85065
16:34Fossi1and way to write the macro in a way that i don't have to pass in the last two params every time?
16:35Fossi1i'd like to use local vars in the macro not 'full.name.space/name
16:35Fossi1which it extends to
16:35kotarakWhy do you need a macro?
16:35Fossi1hmmm. good point
16:35kotarak`(let [this-is-local# ...] ...) note trailing #
16:36Fossi1actually, with a function, i'd have to pass those params
16:36Fossi1no, i don't mean local to the macro
16:36Fossi1i meant local to the calling context
16:37broolFossi1: maybe you want ~'var
16:37Fossi1as in (let [x 'something] (macro-that-wants-to-use-x))
16:37kotarakFossi1: You can capture variables with ~', but you don't want to do that.
16:37Fossi1ah, let me try
16:37Fossi1kotarak: why don't i?
16:37Fossi1i'm pretty sure i do
16:38kotarakFossi1: Because this will lead to terribly spaghetti code and will come back to haunt you...
16:38kotarakFossi1: It's bad style. You'll need more energy to understand the code.
16:38Fossi1yes, i know. it's only in a very contained place though and just to save me from typing it all over
16:38broolif it's a macro local to this code, is it that bad?
16:39kotarakNow it's maybe ok, but in half a hear it might look different.
16:39Fossi1well, if it does, then i'll write a whole new part of code around that
16:39Fossi1it's ugly as is anyway
16:40Fossi1i appreciate the warning though
16:41Fossi1i mean, the swap in that thing and all
16:41Fossi1it's nasty. ;D
16:42kotarakproxy does this as well with "this", be sure to document your macro very well.
16:43Fossi1"@@@ captures event and activity. dragons be here." should be sufficient ;)
16:43Fossi1not a big reusable part in any way
16:43Fossi1just want to flash out some proxying without having to type too much
16:43kotarakFossi1: hehe
17:52malim... identifiers in Clojure are way too short
17:54holmakYou are sad that you do not get to type more?
17:54malimdosync? what is that supposed to mean? gimme DoSynchronously
17:55Fossi1pfft
17:55holmakhuffman encoding!
17:55holmakimportant things have short names
17:56Fossi1then do should be really long ;)
17:56malimlazy-cons? what in blazes is a "cons"???
17:56kotarakmalim: if at all, then do-synchronously... ;)
17:56kotarak,(cons 1 nil)
17:56clojurebot(1)
17:56Fossi1,(doc cons)
17:56clojurebot"([x seq]); Returns a new seq where x is the first element and seq is the rest."
17:57Fossi1also, for a lisp, cons is pretty much where it's at ;)
17:57kotarak,(take 10 (cons 0 (iterate inc 1)))
17:57clojurebot(0 1 2 3 4 5 6 7 8 9)
17:57malimsorry guys. just trolling. wanted to see if the channel was alive
17:57Fossi1'8not so much in clojure though)
17:57Fossi1hell, i'm not used to this shitty german layout anymore
17:57kotarakFossi1: get Neo ;)
17:58Fossi1i was thinking about dvorak'ing my keyboard again
17:58Fossi1but this (currently) is a laptop one from my company
17:58Fossi1don't want to mess with it
17:58malimI don't think a keyboard layout setting will hurt
17:58Fossi1i have a typematrix 2030 though
17:59Fossi1can't type dvorak on qwertz. i tried
17:59tomojbeen dvorak here for years
17:59tomojnow programmer's dvorak
17:59Fossi1i occasionally glance down for whatever reason and it totally throws me off
17:59tomojonly problem is my numbers are like classic dvorak which I'm not used to :(
17:59Fossi1since i have to type qwertz pretty often
18:00Fossi1but the typematrix and dvorak are a godsend
18:01malimI heard that qwerty was designed with the goal to slow down people's typing speed, because type writers would trip up easily if you tried typing too fast. is that true?
18:01Fossi1i wonder how people can seriously press ctrl-alt-alt gr(right alt)-? in emacs
18:01Fossi1malim: nobody knows
18:01Fossi1i think it was more about the positions of the heads
18:02tomojFossi1: is that a real keybinding?
18:02Fossi1those had to be spread evenly according to usage
18:02tomojI didn't know emacs knew what alt gr was
18:02Fossi1tomoj: no, but it knows \
18:02Fossi1which is (right alt)-(englisch -)
18:02Fossi1*snglish
18:03Fossi1insane germans
18:03tomojnice, you can get a typematrix 2030 with blank keys
18:04Fossi1yeah
18:04Fossi1and a rubber top
18:04Fossi1typematrix <3
18:04Fossi1i'd buy one again any time
18:05tomojI don't really want a rubber top
18:05tomojI think I'd rather like a blank keyboard
18:05kotarakmalim: I think it was not slowing people down, but putting the keys mechanically of characters used often together apart, to prevent tripping of the stamp thingies. But there are lots of urban legends here...
18:05Fossi1*shrug*
18:05tomojmine's not dvorak anymore anyway, so :)
18:06tomojoh, you can get the skin blank too, cool
18:06Fossi1well, i don't want to get too funky, so collegues can still work at my laptop if need be
18:06Fossi1although they are already confused by standard qwerty 2030 layout
18:07tomojdoesn't your laptop have it's own keyboard anyway?
18:07Fossi1but then again, with everybodies window manager behaving differently, it's almost impossible as is
18:07Fossi1you are always like: "what the hell is the combo for getting to the next desktop" "where is your browser" etc
18:08tomojmy stumpwm will trip them up for sure :)
18:08Fossi1tomoj: yes, but i have it 'docked'. it's on a stand and connected to a monitor and so on
18:09Fossi1tomoj: almost nothing somebody hasn't been running here :)
18:09Fossi1although xmonad is more popular than stump
18:10tomojnice, even more esoteric
18:10Fossi1lots of haskell lovers around ;)
18:10clojurebotYo dawg, I heard you like Haskell, so I put a lazy thunk inside a lazy thunk so you don't have to compute while you compute.
18:11Fossi1;D
18:11Fossi1clojurebot: <3
18:11clojurebot<3 is ♥
18:11Fossi1hell yeah.
18:12tomojwhy isn't there a clojure window manager
18:12Fossi1running in linux?
18:12Fossi1that could get interesting/annoying to code
18:13tomojhow come?
18:13Fossi1i don't know. i just guess
18:13Fossi1also, i didn't want to write linux, but java
18:13malimI don't think any Linux window manager has been coded in a VM language
18:14Chousukethe lisp ones don't count? :/
18:14tomojhttp://sourceforge.net/projects/escher/
18:14Fossi1just came up with that too
18:14malimwell, I guess they do then
18:14Fossi1so the hard part is 'done'
18:15tomojI dunno anything about window managers
18:15malimyeah, all the JNI =P
18:15hiredmansawfish uses guile
18:15tomojI don't need much from mine though
18:15Fossi1doesn't seem so active though
18:15arbschtprobably the main reason why it doesn't exist is that nobody has yet cared to try. I can't imagine there is any inherent technical obstruction
18:15kotarakhiredman: ? did say switch, I though they use rep or how it was called.
18:16kotaraks/say/they/
18:16hiredmanmaybe they switched to rep?
18:16hiredmanI haven't looked at sawfish in a long time
18:16kotarakhiredman: dunno... haven't used it for years.
18:17Fossi1also about a javavm window manager, what's the point?
18:17tomojI just want to hack it in clojure
18:17malimit'll be cross platform!!!
18:17Fossi1omg
18:17tomojthough I am happy with common lisp too
18:18Fossi1yeah
18:18Fossi1i guess that's about it
18:18malimSCBL?
18:19tomojI just parsed "common lisp" as like "peasant lisp"... clojure is getting to me
18:19malimI read the "Lisp is not an acceptable Lisp" blog yesterday. man did that guy nail it down (maybe except when he says no lisp will ever be acceptable)
18:19hiredmangnome seems to be moving to javascript as their scripting/plugin language, so possible you could use clojurescript
18:22hiredmanhttp://live.gnome.org/Seed
18:23hiredmanI'm just glad to see something that isn't python I guess
18:27malim"Dynamic vars provide a way to communicate between different points on the call stack without polluting the argument lists and return values of the intervening calls." That's just a way of avoiding the term "globals"
18:27Fossi1"My prediction: someone will get tired of waiting, and they'll Torvalds Arc into obsolescence before it's ever released." Hello, rhickey ;D
18:27malimFossi1: yep. that's what I'm hoping
18:28malimClojure is really solving a lot of Lisp's problems.
18:29tomojare many clojurists actually optimistic about clojure as a lisp revival? or is that just a cool t-shirt slogan?
18:30hiredmanmalim: when you dynamically bind a var, the binding only is in effect in the scope of the binding
18:30hiredmanso it is not global
18:30kotarakI don't really care for Lispness. I like Clojure as itself. For its consistency, small core, functionalness, lazy seqs, ... It was called a Blub, I would still use it.
18:31hiredmanthe small core and the functional programing
18:31malimit's not called Lisp though, it's called Clojure =-()
18:32tomoj...and the macros :)
18:32kotarakOh. And I like homoiconicety or how it is called. For the macros. :)
18:32malimconcurrency support
18:32kotarakAlthough I stay away from macros where ever possible.
18:33Fossi1the best part about clojure is actually being able to sell it to clients
18:33Fossi1(as in, programs written in it)
18:33tomojthat's because of java?
18:34Fossi1the jvm, yeah
18:34hiredmanwhen it comes time to port clojure to other platforms, the concurrency stuff is going to be a real headache
18:34Fossi1customers don't care what you write code in, as long as it runs in a tomcat (or such)
18:34Fossi1i don't think clojure will be ported much
18:35Fossi1it runs on webservers in a container and on android
18:35hiredmanoh it will
18:35Fossi1what more is there in the world?
18:35malimported to what? CLR?
18:35hiredmanthere is a javascript port already (but on maintened at the moment waitinf for cinc)
18:35hiredmanyeah the CLR
18:35hiredmanthe ObjectiveC runtime so it can get on the iphone
18:35Fossi1i doubt it
18:36arbschtthere is a clojure-clr port underway already
18:36Fossi1i guess there will rather be either an android port for the iphone or a dalvik
18:36hiredmanthere have already been *3* clr ports
18:36tomojhm.. I think iphone is a bit of a problem
18:36Fossi1or similar jvm
18:36hiredmanonly one is sort of semi official
18:36tomojwe have macruby, but it can't be used on the iphone
18:36hiredman~problem
18:36clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
18:36tomojmaybe the problem with macruby wouldn't affect clojure? I dunno much about it
18:36Fossi1well, a port with a big userbase i mean
18:36hiredman~problem
18:36clojurebotPeople have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
18:36hiredmanbah
18:37hiredman~literal [?] problem
18:37clojurebot2
18:37hiredman~literal [1] problem
18:37clojurebot<reply>People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....
18:37hiredman~literal [0] problem
18:37clojurebot<reply>"There is no problem in computer programming which cannot be solved by an added level of indirection." -- Dr Maurice Wilkes
18:37hiredmanthats the one I was looking for
18:37tomojunless apple says NO :(
18:38malimwhat about the problem of having too much indirection?
18:38Fossi1i'd be happy for a dalvik/dex compiler, but that's about as much portage i need ;D
18:38hiredmanapple snapple
18:38hiredmanmalim: sshh
18:38Fossi1there are some jvms for the (cracked) iphone
18:38Fossi1but they suck ;D
18:38hiredmanjamvm
18:39Fossi1actually, somebody tried clojure with anything else then sun's?
18:39malimthe crakphone
18:39hiredmanFossi1: yeah
18:39Chousukemalim: but since indirection solves all problems, it can't *be* a problem.
18:39hiredmanibm's at least
18:39Fossi1ecj might be nice
18:39hiredmanecj is just a compiler
18:39Fossi1at least for repl stuff
18:39hiredmannot a jvm
18:40Fossi1well, okay
18:43hiredmanjamvm is a jvm written mostly in java, I seem to recall clojure working on that, but it was kind of slow
18:44malima jvm written in java? how does that work? native-complied java?
18:45hiredmanoh
18:45hiredmanacutally jamvm is not the one written in java
18:45Fossi1jamvm is slow for everything ;)
18:46hiredmanmalim: same way you rewrite clojure in clojure
18:46Fossi1then again hotspot has quite some years of experience
18:46Fossi1and the gc rocks (mostly)
18:46hiredmanhttp://en.wikipedia.org/wiki/JikesRVM
18:46hiredmanjikes is the one written in java
18:46hiredman"meta-circular style"
18:52markaddlemanis there some root binding that controls the number of nested exceptions printed out on the repl? i couldn't find it a reference in the docs
18:52hiredman,(doc *print-level*)
18:52clojurebot"; *print-level* controls how many levels deep the printer will print nested objects. If it is bound to logical false, there is no limit. Otherwise, it must be bound to an integer indicating the maximum level to print. Each argument to print is at level 0; if an argument is a collection, its items are at level 1; and so on. If an object is a collection and is at a level greater than or equal to the value bound to *print-l
18:52hiredmandunno if that effects exceptions
18:53hiredmanyou can access a full stacktrace from *e
18:53hiredman,(doc *e)
18:53clojurebot"; bound in a repl thread to the most recent exception caught by the repl"
18:54markaddlemanah. *e gives me what i want. the *print-level* binding doesn't seem to affect stack trace depth
18:54markaddlemanthanks!
19:02malimhmm. what's the equivalent to progn?
19:02kotarakdo
19:02kotarak,(do 1 2 3)
19:02clojurebot3
19:02malimthanks
19:07malimin the repl I'm gettings "java.lang.Exception: Unable to resolve symbol: in this context (NO_SOURCE_FILE:0)"... is it supposed to print the symbol in question after the first ":"?
19:07malimerr, the second ":"
19:07Chousukeyes.
19:07kotarakmalim: maybe some messed utf-8 char
19:07Chousukemaybe you have a symbol that's just whitespace.
19:07Chousuke, 
19:07clojurebotEOF while reading
19:07Chousukehmm
19:07neilmockis wrapping variables in * idiomatic or does it do something extra? (def *var*)
19:08Chousukeclojurebot is smarter :/
19:08hiredman,(symbol " ")
19:08clojurebot
19:08Chousukeneilmock: idiomatic.
19:08hiredmanuh
19:08kotarakneilmock: it's idiomatic for these you might want to re-"define" in a binding
19:08hiredmanre-bindg
19:08kotaraks/these/thing/
19:08Chousukeneilmock: it means it's intended to be dynamically rebound, usually.
19:09Chousukethough it might be a constant too
19:09hiredmanre-"define" makes me cringe
19:09kotarakhehe, that's what the " are for. ;)
19:10hiredmanit just gives the wrong a idea
19:10hiredmanbind is a nicer verb
19:10ChousukeI've seen people who thought of *foo*-variables as global variables like in C or something. :/
19:11Chousukesuperficially I guess they do look like global variables. they are global, after all. But they're not variables :)
19:12Fossi1i guess for the iphone it'll be dual booting android
19:12Fossi1shouldn't be far off
19:13hiredman:|
19:13hiredmangreat
19:13ChousukeI'm loathe to even use the word variable, but sometimes "binding" just sounds wrong :/
19:13hiredmanI hate dual booting
19:13Fossi1and there you have your clojure 'port' ;D
19:13Fossi1i guess you could only boot android
19:13hiredmandual booting is so dumb
19:13hiredmanit is just a work around for not having enough computers
19:14Fossi1well, i don't think apple will allow anything more integrated
19:14Fossi1and voila, no clojure :(
19:14hiredmanFossi1: just buy an android device
19:14Fossi1i'd rather have clojure on android on iphone then not having it
19:14Fossi1well, i own an openmoko freerunner, i run android (or any jvm actually) if i want ;p
19:15hiredmanyou would have to be an idiot to want to buy and iphone to run android on it
19:15Fossi1i know a lot of people are eager to try some android apps on the iphone
19:15hiredmansure, they want android apps
19:15Fossi1if only because writing stuff for it is such a pita
19:15Fossi1(the iphone that is)
19:16hiredmanthat is not the same thing as wanting to run the android OS
19:16Fossi1hell, even the core libraries have memory leaks
19:16hiredmanand those people are all devs
19:16hiredmandevs are crazy anyway
19:16Fossi1sure ;D
19:16Fossi1i don't care about non-crazy people ;D
19:16Fossi1masses can use whatever ;p
19:17hiredmanwell non-crazy people buy more phones then crazy people
19:17Fossi1nokia if they must
19:17Fossi1i'm selfish that way
19:17hiredmandual booting is just horrible
19:17Fossi1also, i'm not trying to make a living out of this :)
19:17hiredmanI hate it, I wish it would go away, along with booting in general
19:17Fossi1i'd be even crazier if i were ;)
19:18hiredmanalways on/instant on
19:18Fossi1well, i agree on that
19:18hiredmanpersitent state
19:18Fossi1but still, if i have an option of running clojure apps on the iphone through dual boot, or not at all, the choice is clear
19:18Fossi1one has to admit that the hardware is dead sexy
19:19hiredmanor just don't buy an iphone
19:19hiredmanI don't have to admit any thing
19:19hiredmanand I never will
19:19Fossi1as said, i own a freerunner ;D
19:19hiredmanI'd like an android phone
19:20hiredmanbut I'd never buy an iphone, because it lacks the feature I find most valuable
19:20hiredmanthe ability to write lua scripts on the phone :P
19:21Fossi1well, you can write the scripts ;)
19:21Fossi1also, i bet there's a lua for the iphone
19:22hiredmanthe openess of the android platform vs. the closedness of the iphone is just another feature like 3G, why would you buy a phone without 3G if you want a phone with 3G?
19:22Fossi1because you value other features more
19:23Fossi1by all means, i'm not saying that anybody should buy one. just that it's sexy ;)
19:23hiredman*snort*
19:25malimhave you guys looked at Java 7?
19:29malimyeah. pretty lackluster
19:31markaddlemanis there a way to pass data from an inner function to the outter function using vars? as i understand the behavior, when exiting scope, a var will rebind to the value in the outter func thus losing whatever value i set in the inner func
19:32hiredmanmarkaddleman: what do you mean inner function to the outer function?
19:32hiredmanlexically nested?
19:32hiredmana function called inside another function?
19:32hiredmanetc
19:32markaddlemanyes
19:32hiredman"yes" is not very descriptive
19:33markaddleman(thanks for clearing up lexically nested... my CS courses were a LONG time ago)
19:33markaddlemansorry. i mean this: (outter-fn (inner-fn ...))
19:33hiredmanthe best design is to have the inner function evaulate to whatever you need
19:33kotarak,(binding [*print-dup* nil] (let [inner-fn (fn [] (var-set *print-dup* "Hello, World")) outer-fn (fn [] (println *print-dup*) (inner-fn) (println *print-dup*))] (outer-fn)))
19:33clojurebotjava.lang.NullPointerException
19:35hiredmanmarkaddleman: it troubles me that you would go looking outside the normal function call/return mechanism
19:35markaddlemanhiredman: agreed.
19:35hiredmanIt can be done and I am sure there are a million different ways to do it
19:35hiredmanmarkaddleman: so don't ask about it and don't do it :)
19:36markaddlemanthe issue here is that i've got some meta data that needs to ride along the thread without changing the inner-function's calling/return semantics
19:36markaddlemanlol... i'd love that
19:36markaddlemanhere's what i'm trying to do: i'm trying to write a commit-scope function. it takes a scope-obj (like a java.sql.Connection) and a no-arg fn. the scope objs need to pass along the thread
19:36kotarak,(binding [count 0] (let [inner-fn (fn [] (var-set count 5)) outer-fn (fn [] (println count) (inner-fn) (println count))] (outer-fn)))
19:36clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Var
19:36hiredmanmarkaddleman: are you familar with binding?
19:37markaddlemanmaybe not as much as i should be
19:37kotarak,(binding [count 0] (let [inner-fn (fn [] (var-set (var count) 5)) outer-fn (fn [] (println count) (inner-fn) (println count))] (outer-fn)))
19:37clojurebot0 5
19:38markaddlemanah.. . i think i just understood a bit deeper. the var only rebinds when exiting a nested bind, not when exiting the nested func
19:39hiredmanmarkaddleman: I don't understand why you need to pass a second value out of the inner function
19:41markaddlemanif the code is (with-commit-scope obj1 #(with-commit-scope obj2 (fn[] "hello"))), i need to pass "hello" up from the inner commit scope to the outter but i also need to pass obj2 up
19:42markaddlemanit would be cool obj2 could hitch a ride on "hello"'s metadata, but, of course, you can't attach metadata onto a string. so i need to pass it along the thread somehow
19:42kotarakLet with-commit-scope return [return-val commit-obj].
19:42hiredmanyou have three inner functions there
19:43hiredmanor three function inside the outer call to with-commit-scope
19:44markaddlemankotarak: that was my first implementation, but it fails because it changes the return semantics of the ultimate function that gets called (in this case the no-arg returning "hello")
19:46kotarakmarkaddleman you could use a wrapping master fn/macro: (with-commit-scopes (scope obj1 (scope obj2 #(do "Hello"))) which does the unwrapping of the return value and the handling of the final scope-object.
19:47markaddlemankotarak: thanks! i just had that idea when you gave your example a couple of minutes ago. i'm coding that up right now
19:47markaddlemanwhat was killing me before is that i was including a binding call in ever with-commit call when i should only have one in the outter most call
20:05Fossi1<3 toString
20:05Fossi1i'm off. bye
20:14rlbFor a general subsystem (say to communicate with mpd), would you tend to expect a multimethod-style interface, or something else? i.e. (play mpd) (pause mpd), etc.
20:38fsmAnyone home?
20:40opqdonutnot home
20:43fsmI am working on my learning project, I am looking for feedback on my code if anyone wants to look
21:00mebaran151I'm having trouble writing this sort of function: I'd like to walk through a nested hash, replacing every hash that has only number keys with a vector, afterwich I'd go into the resulting vector and repeat the process until I reached an atomic value like a string or int
21:08hiredmanmebaran151: http://clojure.org/other_libraries#toc5
21:08mebaran151hmmm
21:09mebaran151I looked at it, but it didn't seem to return a nested hash like I'd like
21:10hiredmanyou can create your own zippers
21:10hiredmanthat use hashes
21:10hiredman,(doc clojure.zip/zipper)
21:10clojurebot"([branch? children make-node root]); Creates a new zipper structure. branch? is a fn that, given a node, returns true if can have children, even if it currently doesn't. children is a fn that, given a branch node, returns a seq of its children. make-node is a fn that, given an existing node and a seq of children, returns a new branch node with the supplied children. root is the root node."
21:11mebaran151I'll work through it
21:12hiredman,(clojure.zip/zipper map? seq (partial into {}) {})
21:12clojurebot[{} nil]
21:12hiredman,((paritial clojure.zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c})
21:12clojurebotjava.lang.Exception: Unable to resolve symbol: paritial in this context
21:13hiredmanbah
21:13hiredman,(require '[clojure.zip: as zip])
21:13clojurebotInvalid token: clojure.zip:
21:13hiredman,(require '[clojure.zip :as zip])
21:13clojurebotnil
21:13hiredman,((partial zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c})
21:13clojurebot[{2 :a, 3 :b, 4 :c} nil]
21:14hiredman,(-> {2 :a 3 :b 4 :c} (partial zip/zipper map? seq (partial into {})) zip/next zip/next zip/next zip/node)
21:14clojurebotjava.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap
21:14hiredmanwhat?
21:15hiredman,(-> ((paritial zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c}) zip/left)
21:15clojurebotjava.lang.Exception: Unable to resolve symbol: paritial in this context
21:15hiredmanok
21:15hiredmananyway
21:34mebaran151thanks hiredman
22:20duck1123is there a better way to get a literal reference to a namespace in my code than (find-ns 'clojure.core)
23:41cemerick*argh* Quoth NetBeans core dev: "javac doesn't need it [so bugger off]".