#clojure logs

2008-09-21

10:10Chouser(contains? [1 2] 0.5) ==> true
10:11Chouserwhich is fine, I guess, since ([1 2] 0.5) ==> 1
10:30rhickeyChouser: no, that seems bogus, but there's no efficient test for integer, need to check for Integer, Long, BigInteger etc...
10:49ChousercontainsKey already does ((Number) key).intValue()
10:49Chouserwould comparing that to key work?
10:50rhickeysure, the problem is not the logic, it's the cost. there generic math, rebox etc
10:54Chouser(find [:a :b] 1/2) ==> [1/2 :a]
12:38Chouserrhickey: how did you not just give up halfway through your dozen'th implementation of Iterator
12:42rhickeyChouser: the payoff is big, all of Clojure's generality, but yeah...
13:05rhickeymade vectors enforce integer keys - rev 1036
13:54lisppaste8joubert annotated #67182 with "fn from method name without reflection" at http://paste.lisp.org/display/67182#1
14:20jgracinI wonder why slime-eval doesn't work... (slime-eval '(+ 1 2)) throws "evaluation aborted". Consistently.
14:22jgracinI should probably use some variant which sends strings because Emacs won't be able to read Clojure's exprs anyway.
16:55arohnerwhat is the best type hint for a clojure map? is that a good idea?
16:56rhickeyno type hints are needed for any Clojure objects
16:56arohneroh, because they're all IFns?
16:56rhickeyonly useful for objects on which you make '.' calls
16:57rhickeycalls to maps and other Clojure data types never use reflection
16:57arohnerah, ok
16:57arohnerthanks
17:16Chouserrhickey: was the ArraySeq Object array patch for performance on the TSP? or for some other reason?
17:18rhickeyPerf in general - I didn't realize the Array calls were reflective, so use direct calls when it's an Object[] array, which is usually
17:19ChouserOk. My JS port of ArraySeq has an optional length arg to allow the seq to end before the end of the array.
17:19ChouserI use that in my variatic argument handling.
17:44achim_phi! is there a smooth way of telling whether a symbol is free/bound in the current context?
17:44achim_pright now i'm doing this: (defn free? [sym] (let [free (gensym)] (= free (try (eval sym) (catch Exception e free)))))
17:44rhickeyresolve:
17:44rhickeyuser=> (resolve 'foo)
17:44rhickeynil
17:44rhickeyuser=> (resolve 'find)
17:44rhickey#'clojure/find
17:46achim_pah, of course ... much easier - thanks!
17:51achim_prhickey: but that works for vars only, not for lexically scoped bindings
17:52rhickeyare you talking about compile time or runtime?
17:53rhickeylexically scoped binding disappear at runtime
17:58Chouserheh, calling clojure.instance_QMARK_ from hand-written JS seems a little awkward.
18:19achim_prhickey: "macroexpand time", i guess ... i was trying to write a defn macro with simple pattern matching, i thought about something like (let [a 10] (defn-p anything [x a] ..only x rebound in here..)), but i think i'm up a blind alley here.
22:19Chouserrhickey: I sure you didn't go just a little crazy with the inheritence stack?
22:19Chousers/I/Are you/
22:19rhickeyhow so?
22:20Chouserheh, dunno, just asking. IObj?
22:21rhickeyhow can you tell if something supports metadata? if not interface, you dictate derivation from concrete class - always wrong
22:22ChouserI think I need to match your hierarchy, for the various type predicates and such to work
22:23Chouseralways wrong? There's a chance something besides Obj will ever implement IObj?
22:23rhickeyVar does
22:23Chouserok, ok. I should know better by now than to doubt you.
22:24rhickeybut even if it didn't, every abstraction should have an interface, else you eventually get screwed
22:24rhickeycompare java.io to java.util
22:25Chousersorry, this task is dull and I'm being unnecessarily cranky.
22:25rhickeyjava.io is a huge pain, no interfaces, not extensible, very awkward
22:26rhickeyjava.util has interfaces for all core abstractions, much easier to use and extend
22:26rhickeyto the extent we have ? predicates you can implement them however you want
22:29Chouserhm...
22:30Chouserwe wouldn't need (instance?) to return the same results?
22:41rhickeyat some point you have to stop short of re-implementing all of Java
22:44Chouserindeed
22:46ChouserI'd like as much of boot.clj as possible to work un-altered.
22:47rhickeysome of that can be dealt with by moving things into RT, I'd be perfectly fine with that - limiting the direct Java references