Re: Test for whether a function accepts a particular arity.

2010-10-29 Thread AlexK
You can use some Reflection to find out if the function has implemented the matching invoke(args*) method see: http://gist.github.com/654851 On 29 Okt., 07:02, Ken Wesson wrote: > (defn accepts-arity? [n f] >   (reduce >     #(or >        %1 >        (= n (count %2)) >        (and (= '& (last (b

Re: ?: promotion of integral types

2010-05-05 Thread AlexK
em is that the primitive versions return primitives and thus cannot overflow to Bignums, so they throw an exception. This 'bug' is unsolvable for now (until we get Fixnums on the JVM) without sacrificing the speed of primitive math. AlexK On 5 Mai, 14:44, Sean Devlin wrote: > Yeah,

Re: Inconsistent behavior in 1.2.0-master w.r.t. previous versions

2010-01-27 Thread AlexK
and thus Maps, Symbols and Vectors aren't instances of Obj anymore. PersistentList extends ASeq which extends Obj directly, so those work. No idea why PersistentSet works however. AlexK -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Does clojure have same problem as groovy "private fields and private methods are not private"

2009-12-24 Thread AlexK
Clojure solves this problem in a very simple way: Not at all. Two Reasons: There is no way to create a class with private members in clojure. 'private members' exist because of lexical scoping and don't require special constructs like 'private' etc. (javascript has 'private members' too because of

Re: Eval question

2009-12-21 Thread AlexK
clojure is a lisp, so it has a "real" eval, that works on datastructures, not strings eg. (eval '(+ 1 2)) ; => 3 (eval (list (symbol "+") 1 2)) ; => 3 whenever you write someting like (def x 3), it gets turned into a list with the symbol 'def, the symbol 'x and the number 3, which then is passed

Re: eval performance

2009-12-21 Thread AlexK
What eval does, is wrapping (fn* [] ) around its arguments, compiling that, and calling the resulting function object (except if your list starts with a 'do or a 'def). While Clojure's compiler is pretty fast, you should try not to use eval. If you want to pass code around you should try something

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread AlexK
On 13 Nov., 17:07, Rich Hickey wrote: > This kind of do-nothing microbenchmarking demonstrates nothing. > Protocol dispatching is significantly faster than multimethod > dispatching, and I haven't even looked into call-site optimization. > Protocol dispatch is not as fast as interface dispatch,

Re: Datatypes and Protocols - early experience program

2009-11-13 Thread AlexK
Hi everybody, after playing around with protocols & datatypes, I found them very fun to use. Some questions: Performance I don't see (with my limited benchmarking) any significant difference between multifns and protocolfns: user=> (defprotocol Test (protocol-fn [it] "Protocol-fn")) Test user=> (

Re: Transient Data Structures

2009-08-07 Thread AlexK
On 7 Aug., 10:07, Patrick Sullivan wrote: > > Am I doing something silly here or is this a bug? You probably are using conj! for the side-effect, but after growing the hashmap to size 8 conj! returns a different map. user> (def foo (transient {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8})) #'user/ foo us