Fork me on GitHub
#clojure
<
2017-10-07
>
donyorm09:10:41

So I'm trying to create an IFn from a java Runnable in java code (using clojure.java.api.Clojure for interop). What's the best way to do this? Using Clojure.read can't create an annonymous functions, and I'm not sure how to create an annonymous function with Clojure.var

leonoel09:10:06

the easiest way is to subclass AFn

donyorm09:10:42

Right. That's a lot of overrides to do. Just wanted to make sure that this wasn't handled in the api.

leonoel09:10:13

AFn has default implementations for the whole IFn interface, just override the ones you need

donyorm09:10:34

oh I thought you typoed on IFn, let me look up afn

leonoel09:10:48

AFn is concrete and is actually used by many of clojure's concrete types

donyorm09:10:35

That worked, thanks for the help

mx200013:10:48

Hi, how to use cemerick/friend and ring anti forgery tokens together? I get a failed login when adding forgery token field

mx200014:10:05

Oh I deleted the user 🙂

didibus17:10:38

Am I wrong to assume seq will realize a lazy sequence? I thought converting it to a non lazy sequence would fore realize it

noisesmith17:10:34

seq does not realize a lazy-seq

noisesmith17:10:06

+user=> (type (seq (map inc (range))))
clojure.lang.Cons
+user=> (type (rest (seq (map inc (range)))))
clojure.lang.LazySeq

noisesmith17:10:45

it only makes the outermost element non-lazy

didibus17:10:26

What does that mean? What would be different between LazySeq and ChunkedCons ?

didibus17:10:34

If the elements are lazy thunks

noisesmith18:10:22

it replaces the first pair of the linked list with a ChunkedCons which is a kind of cons pair

noisesmith18:10:46

if the input were chunked a whole "chunk size" elements would have been realized

noisesmith18:10:03

but it doesn't realize the whole thing - after the first pair / pairs the rest is still a lazy-seq

didibus23:10:53

Okay, that's a bit strange. I guess its because it reads the head, and then the tail just points to the rest of lazy-seq?

noisesmith23:10:07

yes, that's exactly it

didibus23:10:31

Ok, thx for the info