It seems like the polymorphism of protocols breaks inside the
methods. This is a problem for having a function that's polymorphic
between an object and a container of the same objects.

For instance:

user=> (defprotocol Tune (tweek [this]))
Tune
user=> (deftype Knob [name] Tune (tweek [this] (println "Tweeked" name)))
user.Knob
user=> (def base (Knob. "base"))
#'user/base
user=> (tweek base)
Tweeked base
nil
user=> (def treble (Knob. "treble"))
#'user/treble
user=> (tweek treble)
Tweeked treble
nil
user=> (deftype Box [& knobs] Tune (tweek [this] (for [knob knobs] (tweek 
knob))))
user.Box
user=> (tweek (Box. base treble))
user=> (tweek (Box. base treble))
java.lang.IllegalArgumentException: Don't know how to create ISeq from: 
user.Knob
(user=> 

Where what I really want to happen is to tweek all the knobs in the
box. Unfortunately, tweek inside the method seems to be wired to the
method it's in, and no longer polymorphic. I've tried various ways to
get to the variable I want, and some hinting, but nothing seems to
change what I'm getting here.

Maybe I shouldn't be trying to use protocols and types for this? Can
someone let me know what I need to do to make this happen?

        Thanks,
        <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to