Re: Following type annotations across call sites to eliminate reflection?

2016-05-23 Thread Phillip Lord
I macro'd this out (macro's with type-hints are surprisingly tricky). So, you end with this (with-types [val [String Double Boolean]] (C/met val) Which calls C/met with the right thing without reflection (unless you count "instance?"). The code is in tawny-owl. https://github.com/phil

Re: Following type annotations across call sites to eliminate reflection?

2016-05-22 Thread lvh
Hi Reid, > On May 21, 2016, at 11:44 PM, Reid McKenzie wrote: > > You should be able to do this: > > (defn f [a ^bytes b ^bytes c] >(if (instance? ByteBuffer a) > (.f binding ^ByteBuffer a b c) > (.f binding ^bytes a b c))) > > > You have a bimorphic function and yes there isn'

Re: Following type annotations across call sites to eliminate reflection?

2016-05-21 Thread Reid McKenzie
You should be able to do this: (defn f [a ^bytes b ^bytes c] (if (instance? ByteBuffer a) (.f binding ^ByteBuffer a b c) (.f binding ^bytes a b c))) You have a bimorphic function and yes there isn't a way to express that with Clojure's calling convention and consequent hinting supp

Following type annotations across call sites to eliminate reflection?

2016-05-21 Thread lvh
Hi, I’m working on caesium[1], Clojure bindings for libsodium using jnr-ffi. Up until recently, I was able to stick to byte arrays for all APIs; but I’ve started writing new nonce-misuse resistant cryptosystems[2], so I need to have some byte-level layout within a byte array. I’m using java.n