Hello everyone,
I am completely and utterly confused about this error that I just got:
Warning: protocol #'Clondie24.core/MoveCommand is overwriting method
toString of protocol Piece
(defprotocol MoveCommand
"The Command design pattern in action."
(execute [this])
(undo [this])
(getMovingPiece [this])
(getStartPos [this])
(getEndPos [this])
(toString [this]))
(defprotocol Piece "The Piece abstraction."
(update-position [this new-position])
(getGridPosition [this])
(getListPosition [this])
(getPoint [this])
(die [this])
(promote [this])
(getMoves [this])
(toString [this]))
My question is why can't I have a 'toString' method on both protocols?
This is perfectly valid in Java - in fact it's considered good practice
to do that ('clone' and 'equals' too)...Can somebody please elaborate?
an example implementation that I want is this : (unfortunately unless i
change the name to 'asString' or something it complains!)
(defrecord CheckersMove [^CheckersPiece p ;;implements Piece protocol
^clojure.lang.PersistentVector start-pos
^clojure.lang.PersistentVector end-pos]
MoveCommand
(execute [this] (move-checker p end-pos))
(undo [this] (move-checker p start-pos))
(getMovingPiece [this] p)
(getStartPos [this] start-pos)
(getEndPos [this] end-pos)
(toString [this]
(println "Chess-move originating from" (.getStartPos this) "to"
(.getEndPos this))))
Any ideas guys?
Jim
--
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