#clojure log - Aug 08 2009

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

2:30 tomoj: is there a way to check if a var is bound?

2:31 hiredman: clojurebot: vars?

2:31 clojurebot: Excuse me?

2:32 hiredman: I would checkout http://clojure.org/vars

2:32 tomoj: reading that

2:33 hiredman: vars do have an isBound method

2:34 ,(.isBound #'+)

2:34 clojurebot: true

2:34 hiredman: I think you have to try pretty hard to get a hold of a unbound var

2:35 tomoj: holding cookies from login in a var, but if the user hasn't logged in yet, that var is unbound

2:35 guess I can just put {} in the root binding

2:35 hiredman: uh

2:35 seems like a ref or an atom would surely be a better idea

2:36 tomoj: guess I'm thinking in CL

2:36 I'll reread the sections about those

2:38 hiredman: anything where you are rebinding the root value of a var is not good

2:39 tomoj: an atom looks good

3:47 thermalnoise: what is the best way to create an enumeration in clojure? should i define some values in their own ns?

3:48 tomoj: what's the difference between an enumeration and a set?

3:49 thermalnoise: as 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

3:49 tomoj: don't enumerations have more than one value?

3:50 thermalnoise: yes, but only one is "toggled"

3:50 hiredman:

3:50 tomoj: guess I'm not sure how you would use this "enumeration" thing in clojure

3:50 hiredman: just use keywords

3:51 thermalnoise: will read about that. i am new to clojure (coming from the c side)

3:52 tomoj: you don't have to worry about type so much in clojure

3:52 so no need to make new enumeration types

3:52 hiredman: I think enums in a dynamic language are pretty silly

3:54 thermalnoise: @hiredman: care to explain why?

3:56 hiredman: thermalnoise: enums seem to be an artifact of type systems

3:57 you create an enum type that holds one of x defined values and your function returns that enum

4:00 thermalnoise: just 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"?

4:01 hiredman: just use keywords, as I said

4:01 :in-prerp :running :finished

4:01 http://clojure.org/data_structures#toc8

4:01 mikehinchey: if your object is a map {:state :running, :data x}

4:01 thermalnoise: read that moments ago, thanks :)

4:02 mikehinchey: you might have an enum #{:running :finished :in-prep}

4:02 hiredman: mikehinchey: but why?

4:02 mikehinchey: to validate the value of :state

4:02 tomoj: trust vs. flexibility I suppose

4:02 mikehinchey: documentation

4:03 hiredman: docs go in the docstring

4:04 mikehinchey: it depends on how complex it is, I might want to write code around it, give nice error messages, make assertions

4:04 hiredman: *shrug*

4:05 mikehinchey: ok :), just thought I'd answer his question

4:05 hiredman: sure sure

4:08 thermalnoise: @hiredman: just tried keywords and had my d'oh moment for today. thanks for your help.

4:12 jwhitlark: what's the clojure equivalent of python's dir?

4:13 to show all members of a java object.

4:14 looks like show from repl-utils

4:16 tomoj: jwhitlark: nice, I had wondered that myself before

4:18 jwhitlark: I'm trying to get dbus going. not so fun. first the package in ubuntu was broken, now I'm playing with the interface...

4:18 iBong: does slime/swank have a built in command to call javadocs in clojure mode?

4:19 jwhitlark: hiredman: oh, incidentally, your name came up at the BA-clojure meeting last night for always helping people out. It's appreciated.

4:22 tomoj: iBong: I don't think so

4:22 iBong: http://bc.tech.coop/blog/081120.html and http://cynojure.posterous.com/clojure-emacs-and-javadocs look interesting

4:26 jwhitlark: hmmm. Has anyone had any luck with dbus from clojure?

4:36 The new emacs interface to dbus in 23 is certainly cool.

4:42 tomoj: that looks really cool indeed

4:42 when I move from os x to stumpwm that'll certainly come in handy

5:18 is there something prettier than (take-while identity coll) ?

7:31 fsm: Hello everyone.

7:31 I have uploaded my ray tracer source code to http://cray.googlecode.com/ for anyone who is interested.

8:42 slaney: newb q...how can I repeat a string as part of a larger string?

8:42 like in ruby I might have something like 4.times{print "x"}

8:51 I 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

8:51 *had

8:58 Chousuke: ,(apply str (take 4 (repeat "test")))

8:58 clojurebot: "testtesttesttest"

8:58 Chousuke: slaney: ^^

8:58 Neronus: slaney: (reduce str (repeat 4 "x"))

8:58 slaney: oh man

8:58 heh

8:58 Chousuke: apply str is better.

8:58 slaney: apply

8:58 I forgot that one

8:58 tyvm

8:58 Chousuke: uses a single stringbuilder.

8:59 slaney: I am not kidding, I tried for like an hour last night and an hour this morning to come up with something

8:59 hehe

8:59 thanks

9:00 Neronus: Chousuke: I confused that with some argument list length limit; you're right of course

9:34 rhickey: replaca: ping

10:00 duck11231: Are 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:47 tomoj: hmm

10:48 `(range (first vec) (second vec) step)`. better way?

10:50 (eval `(range ~@vec step)) :(

11:04 leafw: any reason why http://clojure.org/api#toc398 exists at all? Looks like a bug in the API generator.

11:05 there are many more such "Macro" API links listed.

11:41 tomoj: grr

11:41 clojure.core/empty is evil

11:58 leafw: (doc empty)

11:58 clojurebot: "([coll]); Returns an empty collection of the same category as coll, or nil"

12:41 LauJensen: Top of the evening guys :) Anybody tried that flu thats going around? Its awesome

13:45 When 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:55 hiredman: LauJensen: where did you hear that?

13:56 LauJensen: clojure.org/atoms

13:57 hiredman: and about refs being async

13:57 ?

13:57 LauJensen: 3.rd paragraph "for which you wish to make synchronous changes (unlike agents, which are similarly independent but asynchronous)."

13:58 hiredman: (still don't see refs)

13:58 agents are deinitely async

13:58 LauJensen: oh yes youre right

13:58 Question remains though

13:59 hiredman: essentially async means operations happen on another thread

14:00 http://clojure.googlegroups.com/web/clojure-conc.png

14:02 tomoj: coordinated means "in a transaction" essentially?

14:03 hiredman: transactions are the reason refs are coordinated

14:04 LauJensen: ok

14:04 hiredman: it 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:08 rlb: If 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:08 Perhaps 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:09 hiredman: sounds reasonable

14:10 rlb: ok, thanks.

14:29 LauJensen: hiredman: So the difference in use-cases for refs and atoms, is basically the coordination? Wether you need it or not

14:33 hiredman: yeah

14:34 LauJensen: Great

14:52 MarkVolkmann: As 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:08 duck11231: If 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:09 kotarak: duck11231: for Java objects (derive Object ::YourGenericName), but for keywords each has to be derived manually.

15:10 duck11231: now 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:10 kotarak: Also possible

16:08 brool: are 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:10 kotarak: brool: type hints, here is a nice example: http://clj-me.blogspot.com/2009/08/what-warn-on-reflection-didnt-tell-you.html

16:10 Otherwise, stress google a little. There was lot of discussion about this and lots of good tips.

16:12 brool: kotarak: 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:12 hiredman: http://clojure.org/java_interop#toc36

16:12 http://clojure.org/java_interop#toc46

16:33 Fossi1: lisppaste8: url

16:33 lisppaste8: To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste.

16:34 Fossi pasted "macro and params" at http://paste.lisp.org/display/85065

16:34 Fossi1: and way to write the macro in a way that i don't have to pass in the last two params every time?

16:35 i'd like to use local vars in the macro not 'full.name.space/name

16:35 which it extends to

16:35 kotarak: Why do you need a macro?

16:35 Fossi1: hmmm. good point

16:35 kotarak: `(let [this-is-local# ...] ...) note trailing #

16:36 Fossi1: actually, with a function, i'd have to pass those params

16:36 no, i don't mean local to the macro

16:36 i meant local to the calling context

16:37 brool: Fossi1: maybe you want ~'var

16:37 Fossi1: as in (let [x 'something] (macro-that-wants-to-use-x))

16:37 kotarak: Fossi1: You can capture variables with ~', but you don't want to do that.

16:37 Fossi1: ah, let me try

16:37 kotarak: why don't i?

16:37 i'm pretty sure i do

16:38 kotarak: Fossi1: Because this will lead to terribly spaghetti code and will come back to haunt you...

16:38 Fossi1: It's bad style. You'll need more energy to understand the code.

16:38 Fossi1: yes, i know. it's only in a very contained place though and just to save me from typing it all over

16:38 brool: if it's a macro local to this code, is it that bad?

16:39 kotarak: Now it's maybe ok, but in half a hear it might look different.

16:39 Fossi1: well, if it does, then i'll write a whole new part of code around that

16:39 it's ugly as is anyway

16:40 i appreciate the warning though

16:41 i mean, the swap in that thing and all

16:41 it's nasty. ;D

16:42 kotarak: proxy does this as well with "this", be sure to document your macro very well.

16:43 Fossi1: "@@@ captures event and activity. dragons be here." should be sufficient ;)

16:43 not a big reusable part in any way

16:43 just want to flash out some proxying without having to type too much

16:43 kotarak: Fossi1: hehe

17:52 malim: ... identifiers in Clojure are way too short

17:54 holmak: You are sad that you do not get to type more?

17:54 malim: dosync? what is that supposed to mean? gimme DoSynchronously

17:55 Fossi1: pfft

17:55 holmak: huffman encoding!

17:55 important things have short names

17:56 Fossi1: then do should be really long ;)

17:56 malim: lazy-cons? what in blazes is a "cons"???

17:56 kotarak: malim: if at all, then do-synchronously... ;)

17:56 ,(cons 1 nil)

17:56 clojurebot: (1)

17:56 Fossi1: ,(doc cons)

17:56 clojurebot: "([x seq]); Returns a new seq where x is the first element and seq is the rest."

17:57 Fossi1: also, for a lisp, cons is pretty much where it's at ;)

17:57 kotarak: ,(take 10 (cons 0 (iterate inc 1)))

17:57 clojurebot: (0 1 2 3 4 5 6 7 8 9)

17:57 malim: sorry guys. just trolling. wanted to see if the channel was alive

17:57 Fossi1: '8not so much in clojure though)

17:57 hell, i'm not used to this shitty german layout anymore

17:57 kotarak: Fossi1: get Neo ;)

17:58 Fossi1: i was thinking about dvorak'ing my keyboard again

17:58 but this (currently) is a laptop one from my company

17:58 don't want to mess with it

17:58 malim: I don't think a keyboard layout setting will hurt

17:58 Fossi1: i have a typematrix 2030 though

17:59 can't type dvorak on qwertz. i tried

17:59 tomoj: been dvorak here for years

17:59 now programmer's dvorak

17:59 Fossi1: i occasionally glance down for whatever reason and it totally throws me off

17:59 tomoj: only problem is my numbers are like classic dvorak which I'm not used to :(

17:59 Fossi1: since i have to type qwertz pretty often

18:00 but the typematrix and dvorak are a godsend

18:01 malim: I 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:01 Fossi1: i wonder how people can seriously press ctrl-alt-alt gr(right alt)-? in emacs

18:01 malim: nobody knows

18:01 i think it was more about the positions of the heads

18:02 tomoj: Fossi1: is that a real keybinding?

18:02 Fossi1: those had to be spread evenly according to usage

18:02 tomoj: I didn't know emacs knew what alt gr was

18:02 Fossi1: tomoj: no, but it knows \

18:02 which is (right alt)-(englisch -)

18:02 *snglish

18:03 insane germans

18:03 tomoj: nice, you can get a typematrix 2030 with blank keys

18:04 Fossi1: yeah

18:04 and a rubber top

18:04 typematrix <3

18:04 i'd buy one again any time

18:05 tomoj: I don't really want a rubber top

18:05 I think I'd rather like a blank keyboard

18:05 kotarak: malim: 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:05 Fossi1: *shrug*

18:05 tomoj: mine's not dvorak anymore anyway, so :)

18:06 oh, you can get the skin blank too, cool

18:06 Fossi1: well, i don't want to get too funky, so collegues can still work at my laptop if need be

18:06 although they are already confused by standard qwerty 2030 layout

18:07 tomoj: doesn't your laptop have it's own keyboard anyway?

18:07 Fossi1: but then again, with everybodies window manager behaving differently, it's almost impossible as is

18:07 you are always like: "what the hell is the combo for getting to the next desktop" "where is your browser" etc

18:08 tomoj: my stumpwm will trip them up for sure :)

18:08 Fossi1: tomoj: yes, but i have it 'docked'. it's on a stand and connected to a monitor and so on

18:09 tomoj: almost nothing somebody hasn't been running here :)

18:09 although xmonad is more popular than stump

18:10 tomoj: nice, even more esoteric

18:10 Fossi1: lots of haskell lovers around ;)

18:10 clojurebot: Yo 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:11 Fossi1: ;D

18:11 clojurebot: <3

18:11 clojurebot: <3 is ♥

18:11 Fossi1: hell yeah.

18:12 tomoj: why isn't there a clojure window manager

18:12 Fossi1: running in linux?

18:12 that could get interesting/annoying to code

18:13 tomoj: how come?

18:13 Fossi1: i don't know. i just guess

18:13 also, i didn't want to write linux, but java

18:13 malim: I don't think any Linux window manager has been coded in a VM language

18:14 Chousuke: the lisp ones don't count? :/

18:14 tomoj: http://sourceforge.net/projects/escher/

18:14 Fossi1: just came up with that too

18:14 malim: well, I guess they do then

18:14 Fossi1: so the hard part is 'done'

18:15 tomoj: I dunno anything about window managers

18:15 malim: yeah, all the JNI =P

18:15 hiredman: sawfish uses guile

18:15 tomoj: I don't need much from mine though

18:15 Fossi1: doesn't seem so active though

18:15 arbscht: probably 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:15 kotarak: hiredman: ? did say switch, I though they use rep or how it was called.

18:16 s/say/they/

18:16 hiredman: maybe they switched to rep?

18:16 I haven't looked at sawfish in a long time

18:16 kotarak: hiredman: dunno... haven't used it for years.

18:17 Fossi1: also about a javavm window manager, what's the point?

18:17 tomoj: I just want to hack it in clojure

18:17 malim: it'll be cross platform!!!

18:17 Fossi1: omg

18:17 tomoj: though I am happy with common lisp too

18:18 Fossi1: yeah

18:18 i guess that's about it

18:18 malim: SCBL?

18:19 tomoj: I just parsed "common lisp" as like "peasant lisp"... clojure is getting to me

18:19 malim: I 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:19 hiredman: gnome seems to be moving to javascript as their scripting/plugin language, so possible you could use clojurescript

18:22 http://live.gnome.org/Seed

18:23 I'm just glad to see something that isn't python I guess

18:27 malim: "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:27 Fossi1: "My prediction: someone will get tired of waiting, and they'll Torvalds Arc into obsolescence before it's ever released." Hello, rhickey ;D

18:27 malim: Fossi1: yep. that's what I'm hoping

18:28 Clojure is really solving a lot of Lisp's problems.

18:29 tomoj: are many clojurists actually optimistic about clojure as a lisp revival? or is that just a cool t-shirt slogan?

18:30 hiredman: malim: when you dynamically bind a var, the binding only is in effect in the scope of the binding

18:30 so it is not global

18:30 kotarak: I 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:31 hiredman: the small core and the functional programing

18:31 malim: it's not called Lisp though, it's called Clojure =-()

18:32 tomoj: ...and the macros :)

18:32 kotarak: Oh. And I like homoiconicety or how it is called. For the macros. :)

18:32 malim: concurrency support

18:32 kotarak: Although I stay away from macros where ever possible.

18:33 Fossi1: the best part about clojure is actually being able to sell it to clients

18:33 (as in, programs written in it)

18:33 tomoj: that's because of java?

18:34 Fossi1: the jvm, yeah

18:34 hiredman: when it comes time to port clojure to other platforms, the concurrency stuff is going to be a real headache

18:34 Fossi1: customers don't care what you write code in, as long as it runs in a tomcat (or such)

18:34 i don't think clojure will be ported much

18:35 it runs on webservers in a container and on android

18:35 hiredman: oh it will

18:35 Fossi1: what more is there in the world?

18:35 malim: ported to what? CLR?

18:35 hiredman: there is a javascript port already (but on maintened at the moment waitinf for cinc)

18:35 yeah the CLR

18:35 the ObjectiveC runtime so it can get on the iphone

18:35 Fossi1: i doubt it

18:36 arbscht: there is a clojure-clr port underway already

18:36 Fossi1: i guess there will rather be either an android port for the iphone or a dalvik

18:36 hiredman: there have already been *3* clr ports

18:36 tomoj: hm.. I think iphone is a bit of a problem

18:36 Fossi1: or similar jvm

18:36 hiredman: only one is sort of semi official

18:36 tomoj: we have macruby, but it can't be used on the iphone

18:36 hiredman: ~problem

18:36 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

18:36 tomoj: maybe the problem with macruby wouldn't affect clojure? I dunno much about it

18:36 Fossi1: well, a port with a big userbase i mean

18:36 hiredman: ~problem

18:36 clojurebot: People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

18:36 hiredman: bah

18:37 ~literal [?] problem

18:37 clojurebot: 2

18:37 hiredman: ~literal [1] problem

18:37 clojurebot: <reply>People have a problem and think "Hey! I'll use a regular expression!". Now they have two problems....

18:37 hiredman: ~literal [0] problem

18:37 clojurebot: <reply>"There is no problem in computer programming which cannot be solved by an added level of indirection." -- Dr Maurice Wilkes

18:37 hiredman: thats the one I was looking for

18:37 tomoj: unless apple says NO :(

18:38 malim: what about the problem of having too much indirection?

18:38 Fossi1: i'd be happy for a dalvik/dex compiler, but that's about as much portage i need ;D

18:38 hiredman: apple snapple

18:38 malim: sshh

18:38 Fossi1: there are some jvms for the (cracked) iphone

18:38 but they suck ;D

18:38 hiredman: jamvm

18:39 Fossi1: actually, somebody tried clojure with anything else then sun's?

18:39 malim: the crakphone

18:39 hiredman: Fossi1: yeah

18:39 Chousuke: malim: but since indirection solves all problems, it can't *be* a problem.

18:39 hiredman: ibm's at least

18:39 Fossi1: ecj might be nice

18:39 hiredman: ecj is just a compiler

18:39 Fossi1: at least for repl stuff

18:39 hiredman: not a jvm

18:40 Fossi1: well, okay

18:43 hiredman: jamvm is a jvm written mostly in java, I seem to recall clojure working on that, but it was kind of slow

18:44 malim: a jvm written in java? how does that work? native-complied java?

18:45 hiredman: oh

18:45 acutally jamvm is not the one written in java

18:45 Fossi1: jamvm is slow for everything ;)

18:46 hiredman: malim: same way you rewrite clojure in clojure

18:46 Fossi1: then again hotspot has quite some years of experience

18:46 and the gc rocks (mostly)

18:46 hiredman: http://en.wikipedia.org/wiki/JikesRVM

18:46 jikes is the one written in java

18:46 "meta-circular style"

18:52 markaddleman: is 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:52 hiredman: ,(doc *print-level*)

18:52 clojurebot: "; *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:52 hiredman: dunno if that effects exceptions

18:53 you can access a full stacktrace from *e

18:53 ,(doc *e)

18:53 clojurebot: "; bound in a repl thread to the most recent exception caught by the repl"

18:54 markaddleman: ah. *e gives me what i want. the *print-level* binding doesn't seem to affect stack trace depth

18:54 thanks!

19:02 malim: hmm. what's the equivalent to progn?

19:02 kotarak: do

19:02 ,(do 1 2 3)

19:02 clojurebot: 3

19:02 malim: thanks

19:07 in 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:07 err, the second ":"

19:07 Chousuke: yes.

19:07 kotarak: malim: maybe some messed utf-8 char

19:07 Chousuke: maybe you have a symbol that's just whitespace.

19:07 , 

19:07 clojurebot: EOF while reading

19:07 Chousuke: hmm

19:07 neilmock: is wrapping variables in * idiomatic or does it do something extra? (def *var*)

19:08 Chousuke: clojurebot is smarter :/

19:08 hiredman: ,(symbol " ")

19:08 clojurebot:

19:08 Chousuke: neilmock: idiomatic.

19:08 hiredman: uh

19:08 kotarak: neilmock: it's idiomatic for these you might want to re-"define" in a binding

19:08 hiredman: re-bindg

19:08 kotarak: s/these/thing/

19:08 Chousuke: neilmock: it means it's intended to be dynamically rebound, usually.

19:09 though it might be a constant too

19:09 hiredman: re-"define" makes me cringe

19:09 kotarak: hehe, that's what the " are for. ;)

19:10 hiredman: it just gives the wrong a idea

19:10 bind is a nicer verb

19:10 Chousuke: I've seen people who thought of *foo*-variables as global variables like in C or something. :/

19:11 superficially I guess they do look like global variables. they are global, after all. But they're not variables :)

19:12 Fossi1: i guess for the iphone it'll be dual booting android

19:12 shouldn't be far off

19:13 hiredman: :|

19:13 great

19:13 Chousuke: I'm loathe to even use the word variable, but sometimes "binding" just sounds wrong :/

19:13 hiredman: I hate dual booting

19:13 Fossi1: and there you have your clojure 'port' ;D

19:13 i guess you could only boot android

19:13 hiredman: dual booting is so dumb

19:13 it is just a work around for not having enough computers

19:14 Fossi1: well, i don't think apple will allow anything more integrated

19:14 and voila, no clojure :(

19:14 hiredman: Fossi1: just buy an android device

19:14 Fossi1: i'd rather have clojure on android on iphone then not having it

19:14 well, i own an openmoko freerunner, i run android (or any jvm actually) if i want ;p

19:15 hiredman: you would have to be an idiot to want to buy and iphone to run android on it

19:15 Fossi1: i know a lot of people are eager to try some android apps on the iphone

19:15 hiredman: sure, they want android apps

19:15 Fossi1: if only because writing stuff for it is such a pita

19:15 (the iphone that is)

19:16 hiredman: that is not the same thing as wanting to run the android OS

19:16 Fossi1: hell, even the core libraries have memory leaks

19:16 hiredman: and those people are all devs

19:16 devs are crazy anyway

19:16 Fossi1: sure ;D

19:16 i don't care about non-crazy people ;D

19:16 masses can use whatever ;p

19:17 hiredman: well non-crazy people buy more phones then crazy people

19:17 Fossi1: nokia if they must

19:17 i'm selfish that way

19:17 hiredman: dual booting is just horrible

19:17 Fossi1: also, i'm not trying to make a living out of this :)

19:17 hiredman: I hate it, I wish it would go away, along with booting in general

19:17 Fossi1: i'd be even crazier if i were ;)

19:18 hiredman: always on/instant on

19:18 Fossi1: well, i agree on that

19:18 hiredman: persitent state

19:18 Fossi1: but 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:18 one has to admit that the hardware is dead sexy

19:19 hiredman: or just don't buy an iphone

19:19 I don't have to admit any thing

19:19 and I never will

19:19 Fossi1: as said, i own a freerunner ;D

19:19 hiredman: I'd like an android phone

19:20 but I'd never buy an iphone, because it lacks the feature I find most valuable

19:20 the ability to write lua scripts on the phone :P

19:21 Fossi1: well, you can write the scripts ;)

19:21 also, i bet there's a lua for the iphone

19:22 hiredman: the 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:22 Fossi1: because you value other features more

19:23 by all means, i'm not saying that anybody should buy one. just that it's sexy ;)

19:23 hiredman: *snort*

19:25 malim: have you guys looked at Java 7?

19:29 yeah. pretty lackluster

19:31 markaddleman: is 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:32 hiredman: markaddleman: what do you mean inner function to the outer function?

19:32 lexically nested?

19:32 a function called inside another function?

19:32 etc

19:32 markaddleman: yes

19:32 hiredman: "yes" is not very descriptive

19:33 markaddleman: (thanks for clearing up lexically nested... my CS courses were a LONG time ago)

19:33 sorry. i mean this: (outter-fn (inner-fn ...))

19:33 hiredman: the best design is to have the inner function evaulate to whatever you need

19:33 kotarak: ,(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:33 clojurebot: java.lang.NullPointerException

19:35 hiredman: markaddleman: it troubles me that you would go looking outside the normal function call/return mechanism

19:35 * kotarak too thinks it's a bad idea

19:35 markaddleman: hiredman: agreed.

19:35 hiredman: It can be done and I am sure there are a million different ways to do it

19:35 markaddleman: so don't ask about it and don't do it :)

19:36 markaddleman: the 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:36 lol... i'd love that

19:36 here'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:36 kotarak: ,(binding [count 0] (let [inner-fn (fn [] (var-set count 5)) outer-fn (fn [] (println count) (inner-fn) (println count))] (outer-fn)))

19:36 clojurebot: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Var

19:36 hiredman: markaddleman: are you familar with binding?

19:37 markaddleman: maybe not as much as i should be

19:37 kotarak: ,(binding [count 0] (let [inner-fn (fn [] (var-set (var count) 5)) outer-fn (fn [] (println count) (inner-fn) (println count))] (outer-fn)))

19:37 clojurebot: 0 5

19:38 markaddleman: ah.. . i think i just understood a bit deeper. the var only rebinds when exiting a nested bind, not when exiting the nested func

19:39 hiredman: markaddleman: I don't understand why you need to pass a second value out of the inner function

19:41 markaddleman: if 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:42 it 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:42 kotarak: Let with-commit-scope return [return-val commit-obj].

19:42 hiredman: you have three inner functions there

19:43 or three function inside the outer call to with-commit-scope

19:44 markaddleman: kotarak: 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:46 kotarak: markaddleman 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:47 markaddleman: kotarak: thanks! i just had that idea when you gave your example a couple of minutes ago. i'm coding that up right now

19:47 what 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:05 Fossi1: <3 toString

20:05 i'm off. bye

20:14 rlb: For 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:38 fsm: Anyone home?

20:40 opqdonut: not home

20:43 fsm: I am working on my learning project, I am looking for feedback on my code if anyone wants to look

21:00 mebaran151: I'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:08 hiredman: mebaran151: http://clojure.org/other_libraries#toc5

21:08 mebaran151: hmmm

21:09 I looked at it, but it didn't seem to return a nested hash like I'd like

21:10 hiredman: you can create your own zippers

21:10 that use hashes

21:10 ,(doc clojure.zip/zipper)

21:10 clojurebot: "([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:11 mebaran151: I'll work through it

21:12 hiredman: ,(clojure.zip/zipper map? seq (partial into {}) {})

21:12 clojurebot: [{} nil]

21:12 hiredman: ,((paritial clojure.zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c})

21:12 clojurebot: java.lang.Exception: Unable to resolve symbol: paritial in this context

21:13 hiredman: bah

21:13 ,(require '[clojure.zip: as zip])

21:13 clojurebot: Invalid token: clojure.zip:

21:13 hiredman: ,(require '[clojure.zip :as zip])

21:13 clojurebot: nil

21:13 hiredman: ,((partial zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c})

21:13 clojurebot: [{2 :a, 3 :b, 4 :c} nil]

21:14 hiredman: ,(-> {2 :a 3 :b 4 :c} (partial zip/zipper map? seq (partial into {})) zip/next zip/next zip/next zip/node)

21:14 clojurebot: java.lang.IllegalArgumentException: Wrong number of args passed to: PersistentArrayMap

21:14 hiredman: what?

21:15 ,(-> ((paritial zip/zipper map? seq (partial into {})) {2 :a 3 :b 4 :c}) zip/left)

21:15 clojurebot: java.lang.Exception: Unable to resolve symbol: paritial in this context

21:15 hiredman: ok

21:15 anyway

21:34 mebaran151: thanks hiredman

22:20 duck1123: is there a better way to get a literal reference to a namespace in my code than (find-ns 'clojure.core)

23:41 cemerick: *argh* Quoth NetBeans core dev: "javac doesn't need it [so bugger off]".

Logging service provided by n01se.net