You shouod also checkout https://github.com/jgpc42/insn/blob/master/README.md
It was annouced a few weeks back, looks like a nice interface to ASM.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegro
I'm not fully following what you're doing or trying to do, but don't expect
meta to compose. A lot of macros and functions can strip it away. Its best kept
to annotate global static things.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to
How do you handle closures?
EG:
(defn squared ^IFn [^IFn f]
(with-meta
(fn squared0 [x]
(let [fx (double (f x))]
(* fx fx)))
{:domain :number
:range :positive-number}))
I think you can do it, but it would require the macro taking apart the
value of &env, which means d
You don't need to indirect - the invoke, call, and apply methods can have
your code in them directly (a macro can expand to put your code body into
them directly as appropriate). If you need to ensure it isn't mistaken for
data, you could add a marker interface and check for it (an interface with
n
I've done something like this in the past.
I'd expect the performance to be similar to MetaFn. In either case, I think
you have a wrapper class that carries the additional data, and one level of
indirection for invoke or invokePrim. My benchmarks results so far seem to
show the indirection gets op
ASM:
I haven't done anything with ASM before. Any advice would be greatly
appreciated.
What I have in mind is using the org.ow2.asm, not the internal clojure.asm.
I am imagining I can take a function's class and add 'implements IObj', a
'meta' field, and the necessary methods, and pass through e
Code generation:
It seems to me this has to be done on demand, to be practical.
To support every possible combination of 'implements clojure.lang.IFn$DD,
clojure.lang.IFn$DLD, ...'
for differing arrities, I get 13,108,878 classes.
Or is there a better way?
On Wed, Sep 20, 2017 at 12:05 PM, John
3rd issue: metadata and function equality:
I've never really understood the motivation for "Two objects that differ
only in metadata are equal."
Is there a good reference for that?
For my purposes, it would probably be better if 'metadata' did affect
equality.
Perhaps I shouldn't be overloading
I've had good luck with an approach suggested by Kevin Downey, defining a
defrecord that implements IFn so that it works when called and applied, and
transparently supporting attached data as if it were a hash-map. It's not
too hard to implement if you know the precise arg count you need to
support
2nd issue: Benchmarks
I use both criterium and simple 'run repeatedly and divide the clock time'.
I've had trouble getting consistent results from run to run with either.
Most recently (yesterday) I've added many more warmup runs, giving HotSpot
lots of time to do its stuff, which seems to be st
Thanks for the quick response.
One issue at a time:
(A) Putting metadata on Vars instead of on the functions themselves:
I need to be able to associate facts with the function instances. I can't
rely on every function being bound to a Var.
For example, I'm constructing cost functions for machine
On Tuesday, September 19, 2017 at 8:01:07 PM UTC-5, John Alan McDonald
wrote:
>
> I'd like to be able to do something like:
>
> (defn square ^double [^double x] (* x x))
> (def meta-square (with-meta square {:domain Double/TYPE :codomain Double/TYPE
> :range {:from 0.0 :to Double/POSITIVE_INFIN
I'd like to be able to do something like:
(defn square ^double [^double x] (* x x))
(def meta-square (with-meta square {:domain Double/TYPE :codomain Double/TYPE
:range {:from 0.0 :to Double/POSITIVE_INFINITY :also Double/NaN}})
https://clojure.org/reference/metadata says "Symbols and collection
13 matches
Mail list logo