Fork me on GitHub
#clojure
<
2015-07-03
>
pupeno06:07:01

Just to confirm, this won’t cause a stack overflow, right: (fn iter [f n] (cons n (lazy-seq (iter f (f n)))))

andrea.crotti09:07:10

@pupeno: that's how iterate is defined

pupeno09:07:02

Cool. Thanks.

slipset10:07:17

Out of curiosity. At euroclojure, Alex Kachayev talked about muse https://github.com/kachayev/muse

slipset10:07:10

And he has code like (fmap set/intersection (friends-of x) (friends-of y))

slipset10:07:40

And I guess what I'm wondering about is if this could have been done with a normal map, if you in some way could tell map to do something special when the collections were muse related.

slipset10:07:32

It seems like the arguments to fmap need to be something which implements the protocol ComposedAST. I guess where I would want to go is if the collections which are passed to the normal map had to implement some protocol IMappable which then the muse datastructures also could have implemented?

kachayev10:07:23

arguments to muse/fmap need to be something which implements the protocol muse/MuseAST or muse/ComposedAST or muse/DataSource (the last one is how it was meant to be used)

kachayev10:07:20

clojure map is targeted to sequence operation (or creates transducer)

kachayev10:07:51

event if you have technical ability to implement this with clojure map, it still will be very confusing for most developers

slipset10:07:29

Yes, but if clojure map was defined in terms of a protocol, you could let your protocols extend the protocol of map

slipset10:07:47

I'm not suggesting you should do this, but I just started thinking about this.

slipset10:07:19

I guess my real question is, what would a protocol for the arguments of map look like

slipset10:07:43

as in, what operations do the collections passed in to map need to satisfy.

slipset10:07:48

seems like first and rest simple_smile

kachayev10:07:49

seems like seq, which means it should implement clojure.lang.ISeq

slipset10:07:09

So, if ISeq were a protocol and not an interface, your protos could extend ISeq and you could have used map?

slipset10:07:08

or maybe protocols can extend interfaces?

tcrayford11:07:19

they can't, afaik. Clojure isn't designed around subtyping (in most of it's places anyway)

Alex Miller (Clojure team)12:07:44

Protocols can extend interfaces

Alex Miller (Clojure team)12:07:25

It can get a bit tricky when a concrete type has multiple applicable paths in a protocol though - it's possible for the choice of path to be arbitrary as protocols have no preference info like multimethods

malabarba17:07:18

Can a proxy override a final method?