And when you say you have reflection warnings, can it be that you call a
protocol method foo with (.foo o) [note the .-syntax]...

I'm not sure what you mean...Of course I'm calling a protocol method with (.update-position p coords) - with the '.'
How else can I call it?

Jim

On 12/06/12 13:28, Jim - FooBar(); wrote:
Of course, I Just noticed that type-hinting 'p' renders the precondition useless...an extra performance bonus!

Jim

On 12/06/12 13:26, Jim - FooBar(); wrote:
On 12/06/12 13:16, Tassilo Horn wrote:
I don't get you.  If IPieces can be moved, then move should be a
protocol method declared in IPiece.

No what i have in IPiece is 'updatePosition' so each piece knows how to update its position. THere is more to a move though. 'move' is a regular function that builds a new board every time...a move might have killed some pieces etc...

And when you say you have reflection warnings, can it be that you call a
protocol method foo with (.foo o) [note the .-syntax]...
I'msure you will understand if you see the code:

(defn move
"The function responsible for moving Pieces. Each piece knows how to move itself. Returns the new board."
 ^clojure.lang.LazySeq
[^clojure.lang.Symbol game mappings ^Clondie24.core.IPiece p coords]
{:pre [(satisfies? IPiece p)]}  ;safety comes first
(if (in? mappings (vector-of-doubles coords)) ;check that position exists on the grid
(do  (.update-position p coords) ;coords should be of the form [x, y]
(reset! (current-items game true) ;replace the board atom
(clean (build-board game)))) ;;replace the old board with the new (throw (IllegalArgumentException. (str coords " is NOT a valid position according to the mappings provided!")))))


Notice the ''(.update-position p coords)" right after 'do'...this is where the reflection was occuring because I could not type-hint the argument correctly! Now it is sorted though (as you can see)...

makes sense now?

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

Reply via email to