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
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,
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.
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
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
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
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,
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=> (
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