#clojure log - Apr 08 2008

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

13:23 drewr: I love that lisps handle rational numbers correctly, but is this the only option when you want a float?

13:23 user> (/ 3 2)

13:23 3/2

13:23 user> (* (/ 3 2) 1.0)

13:23 1.5

13:24 Chouser: (float (/ 3 2))

13:24 drewr: Chouser: You'd think searching the api page I would have found that. :-)

13:24 Chouser: :-)

13:26 I don't know if there's a way to from float to ratio, though.

13:26 drewr: Does it bother anyone else that the docstring comes before the parameters in a function def?

13:27 Chouser: there can be multiple parameter sets.

13:27 In which case any other placement of the docsstring get a bit awkward.

13:28 drewr: OK, multiple arity.

13:28 Chouser: yessir

13:28 drewr: Well, I guess it's a good tradeoff then.

13:30 Chouser: I think that's the rationale, anyway.

13:30 drewr: That's reverse of every Python, elisp, CL, probably others. Trying to get used to it.

13:31 Chouser: well, it's a odd syntax for multiple arity too, but I find I like the convenience.

13:31 drewr: From the code I've read so far, I agree.

13:31 Chouser: It's quite nice for setting up default params.

14:42 (/ (long (* 1.5 1000)) 1000)

15:10 drewr: Chouser: Nice :-)

15:11 rhickey: drewr: what's nice?

15:11 Chouser: (/ (long (* 1.5 1000)) 1000)

15:11 for converting a float to a ratio

15:11 I think he was being fascetious.

15:11 drewr: ;-)

15:13 rhickey: hmm... yes, CL's rationalize

15:14 Chouser: BTW, I'm enjoying the reader syntax discussion in the group, independant of any final decision.

15:15 rhickey: :)

15:16 * drewr too

15:16 Chouser: And I also wish (oh how I wish) to be using Clojure for work instead of C++.

15:17 rhickey: use it to generate C++

15:17 Chouser: heh.

15:18 abrooks: Which thread is the reader thread? ("Syntactic extensibility"?)

15:18 Chouser: abrooks: yes

15:18 I'm reading about composable monkey patching instead of writing C++ code.

15:18 rhickey: will be out in novel form soon

15:18 abrooks: Heh.

15:19 drewr: That explanation of generic functions was the most concise and helpful I've seen.

15:19 rhickey: great!

15:23 Chouser: Is there a way to dispatch multimethods on params other than the first?

15:24 rhickey: sure, the dispatch fn is an arbitrary fn of _all_ of the arguments

15:25 you can use any subset of the arguments, their types, values, attributes, look up in a db, etc

15:25 Chouser: ok, so my confusion may be because all the examples I've seen have methoeds with arity 1

15:26 rhickey: not this one: http://clojure.sourceforge.net/features/runtime_polymorphism.html

15:26 Chouser: ah, ok, that helps. thanks.

15:53 rhickey: user=> (rationalize 1.5)

15:53 3/2

15:53 user=> (rationalize 1.2345)

15:53 2469/2000

16:14 Chouser: :-) thanks.

16:14 the name is from CL? We could have floatize, too.

16:15 rhickey: yes, from CL - you have float already

16:15 abrooks: Chouser: That would be floatnlize. :)

16:16 rhickey: but it's not the same, i.e. not ratio

16:16 (rationalize 1) -> 1

16:16 Chouser: ah, ok.

16:17 (floatnlize 1) -> 1

16:17 rhickey: I don't think so

17:39 MarkJP: hmmm

17:39 user=> (= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) (class Void))

17:39 false

17:39 shouldn't that be true?

17:42 abrooks: Don't you want t wrap (class ....) around the first contained form?

17:42 Or is that your point.. that you shouldn't have to?

17:42 MarkJP: didn't think I had to

17:42 let me try

17:42 that works

17:42 abrooks: Right.

17:43 MarkJP: should I have to?

17:43 doesnt getReturnType return a class

17:43 Chouser: I don't think that's what you mean.

17:43 (class Void) -> class java.lang.Class

17:44 MarkJP: ohhh

17:44 Chouser: so you want just Void not (class Void).

17:44 MarkJP: that doesnt work either

17:44 Chouser: right

17:44 abrooks: I think the comparison still doesn't... work.

17:44 MarkJP: user=> (= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) Void)

17:44 false

17:45 yep

17:45 * abrooks is a little slow.

17:45 abrooks: Need more tea.

17:45 Chouser: getReturnType is returning just void. I'm not sure how that's different from Void.

17:47 MarkJP: got it:

17:47 (= (.. (new Object) (getClass) (getDeclaredMethod "finalize" nil) (getReturnType)) (. Void TYPE))

17:47 Chouser: nice

17:47 MarkJP: thx for setting me straight

17:47 Chouser: What are you working on?

17:48 MarkJP: turning a clojure proxied class into java code :p

17:48 need to know when I have to use the keyword "return"

23:46 Chouser: Shouldn't this work? (binding [x 5] x)

23:47 I 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

Logging service provided by n01se.net