Thanks Lars but there is no difference...when i try to load my namespace
I get this output:
Clondie24.core=> (load-file "src/Clondie24/core.clj")
#'Clondie24.core/-mainReflection warning,
/home/sorted/clooJWorkspace/Clondie24/src/Clondie24/core.clj:104 - call
to setLocation can't be resolved.
Reflection warning,
/home/sorted/clooJWorkspace/Clondie24/src/Clondie24/core.clj:122 - call
to setLocation can't be resolved.
Reflection warning,
/home/sorted/clooJWorkspace/Clondie24/src/Clondie24/core.clj:206 -
reference to field getListPosition can't be resolved.
Reflection warning,
/home/sorted/clooJWorkspace/Clondie24/src/Clondie24/core.clj:251 - call
to update_position can't be resolved.
Of the 4 warnings only the last 2 can be justified (it is not
predetermined what type comes in)...the first 2 refer to 2 different
records that do the same thing as far as updating the position goes and
setLocation is the culprit again!
Jim
On 10/06/12 18:09, Lars Nilsson wrote:
On Sun, Jun 10, 2012 at 1:08 PM, Lars Nilsson<[email protected]> wrote:
On Sun, Jun 10, 2012 at 1:04 PM, Jim - FooBar();<[email protected]> wrote:
Hi again (busy day eh?),
well this doesn't make any sense either! Why is a record with type-hinted
arguments still using reflection?
I've got the following example record:
--------------------------------------------------------------------------------------------------
(defrecord CheckersPiece [^java.awt.Color color
^java.awt.Point position
rank]
Piece
(update-position [this np] ;mutable state inside Point!
(. position setLocation ;can accept ints or doubles
(first np) (second np))) ;np should be [x, y]
(die [this] (vary-meta this assoc :dead true)) ;communicate death
through meta-data
(promote [this] (make-checker color position :rank 'prince)) ; a checker is
promoted to prince
(getGridPosition [this] (vector (.getX position) (.getY position)))
(getListPosition [this] (translate-position (first (.getGridPosition
this))
(second (.getGridPosition
this)) board-mappings-checkers))
(getPoint [this] position)
(getMoves [this] nil) ;TODO
Object
(toString [this]
(println "Checker (" rank ") at position:" (.getListPosition this) " ->"
(.getGridPosition this))) )
---------------------------------------------------------------------------------------------------------------------------
and whenever i call update-position it complains that setLocation cannot be
resolved. setLocation is a method in java.awt.Point so i don't see why this
happens!
Would (.setLocation position) possibly behave differently maybe? Worth a try?
Ehh... With the two arguments I forgot to include in the call obviously..
Lars Nilsson
--
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