Interfaces are more java-y, which has pluses and minuses. Here for example, I think the compiler itself, which is written in java, needs to be able to seq things (ie, your source-code forms). *Maybe* you could make seqable a protocol, but it would make the compiler much less convenient as implementations would have to be registered before it could do anything and so on. There's also a performance implication: interfaces are probably (no tests actually run here) several times faster than protocols, which makes a huge difference for something as fundamental to the language core as sequences.
On Oct 11, 11:13 am, Stathis Sideris <[email protected]> wrote: > Hello all, > Is it possible make an existing Java class behave as a seq? What I'm really > asking I guess, is how come Seqable is not a protocol so that we can say > something like > > (extend-type java.awt.Container > clojure.lang.Seqable > (seq [this] (my-seq-function this))) > > I know this can be achieved at creation time by proxy or reify, but this is > not in the spirit of protocols (which can add behaviour on, after the > definition of the type). Am I missing something? > Thanks, > Stathis -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
