#clojure logs

2008-04-08

13:23drewrI love that lisps handle rational numbers correctly, but is this the only option when you want a float?
13:23drewruser> (/ 3 2)
13:23drewr3/2
13:23drewruser> (* (/ 3 2) 1.0)
13:23drewr1.5
13:24Chouser(float (/ 3 2))
13:24drewrChouser: You'd think searching the api page I would have found that. :-)
13:24Chouser:-)
13:26ChouserI don't know if there's a way to from float to ratio, though.
13:26drewrDoes it bother anyone else that the docstring comes before the parameters in a function def?
13:27Chouserthere can be multiple parameter sets.
13:27ChouserIn which case any other placement of the docsstring get a bit awkward.
13:28drewrOK, multiple arity.
13:28Chouseryessir
13:28drewrWell, I guess it's a good tradeoff then.
13:30ChouserI think that's the rationale, anyway.
13:30drewrThat's reverse of every Python, elisp, CL, probably others. Trying to get used to it.
13:31Chouserwell, it's a odd syntax for multiple arity too, but I find I like the convenience.
13:31drewrFrom the code I've read so far, I agree.
13:31ChouserIt's quite nice for setting up default params.
14:42Chouser(/ (long (* 1.5 1000)) 1000)
15:10drewrChouser: Nice :-)
15:11rhickeydrewr: what's nice?
15:11Chouser(/ (long (* 1.5 1000)) 1000)
15:11Chouserfor converting a float to a ratio
15:11ChouserI think he was being fascetious.
15:11drewr;-)
15:13rhickeyhmm... yes, CL's rationalize
15:14ChouserBTW, I'm enjoying the reader syntax discussion in the group, independant of any final decision.
15:15rhickey:)
15:16ChouserAnd I also wish (oh how I wish) to be using Clojure for work instead of C++.
15:17rhickeyuse it to generate C++
15:17Chouserheh.
15:18abrooksWhich thread is the reader thread? ("Syntactic extensibility"?)
15:18Chouserabrooks: yes
15:18ChouserI'm reading about composable monkey patching instead of writing C++ code.
15:18rhickeywill be out in novel form soon
15:18abrooksHeh.
15:19drewrThat explanation of generic functions was the most concise and helpful I've seen.
15:19rhickeygreat!
15:23ChouserIs there a way to dispatch multimethods on params other than the first?
15:24rhickeysure, the dispatch fn is an arbitrary fn of _all_ of the arguments
15:25rhickeyyou can use any subset of the arguments, their types, values, attributes, look up in a db, etc
15:25Chouserok, so my confusion may be because all the examples I've seen have methoeds with arity 1
15:26rhickeynot this one: http://clojure.sourceforge.net/features/runtime_polymorphism.html
15:26Chouserah, ok, that helps. thanks.
15:53rhickeyuser=> (rationalize 1.5)
15:53rhickey3/2
15:53rhickeyuser=> (rationalize 1.2345)
15:53rhickey2469/2000
16:14Chouser:-) thanks.
16:14Chouserthe name is from CL? We could have floatize, too.
16:15rhickeyyes, from CL - you have float already
16:15abrooksChouser: That would be floatnlize. :)
16:16rhickeybut it's not the same, i.e. not ratio
16:16rhickey(rationalize 1) -> 1
16:16Chouserah, ok.
16:17Chouser(floatnlize 1) -> 1
16:17rhickeyI don't think so
17:39MarkJPhmmm
17:39MarkJPuser=> (= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) (class Void))
17:39MarkJPfalse
17:39MarkJPshouldn't that be true?
17:42abrooksDon't you want t wrap (class ....) around the first contained form?
17:42abrooksOr is that your point.. that you shouldn't have to?
17:42MarkJPdidn't think I had to
17:42MarkJPlet me try
17:42MarkJPthat works
17:42abrooksRight.
17:43MarkJPshould I have to?
17:43MarkJPdoesnt getReturnType return a class
17:43ChouserI don't think that's what you mean.
17:43Chouser(class Void) -> class java.lang.Class
17:44MarkJPohhh
17:44Chouserso you want just Void not (class Void).
17:44MarkJPthat doesnt work either
17:44Chouserright
17:44abrooksI think the comparison still doesn't... work.
17:44MarkJPuser=> (= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) Void)
17:44MarkJPfalse
17:45MarkJPyep
17:45abrooksNeed more tea.
17:45ChousergetReturnType is returning just void. I'm not sure how that's different from Void.
17:47MarkJPgot it:
17:47MarkJP(= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) (. Void TYPE))
17:47Chousernice
17:47MarkJPthx for setting me straight
17:47ChouserWhat are you working on?
17:48MarkJPturning a clojure proxied class into java code :p
17:48MarkJPneed to know when I have to use the keyword "return"
23:46ChouserShouldn't this work? (binding [x 5] x)
23:47ChouserI must be up too late. It seems like that should just return 5 instead of: java.lang.Exception: Unable to resolve var: x in this context