I don't know if it makes a difference, but I was doing AOT compilation
on a file nbody.clj containing the program in my message.
I replied to my own message with a workaround that it seems to be
related to the variable 'nbody' having the same name as the one in the
'ns' declaration.
Thanks,
Andy
On Sep 27, 2010, at 4:14 PM, Stuart Halloway wrote:
That's weird. I see no reflection warnings when loading this on 1.3
alpha 1.
Stu
The following program compiles and runs perfectly fine in both 1.2
and 1.3 alpha1. It has no reflection warnings in 1.2, but it does
in 1.3 alpha1. I have tried several variations, but I haven't yet
been able to figure out how to write type declarations that avoid
reflection in 1.3 alpha1. Does anyone know whether this is a bug?
Or perhaps code like this ought to be structured completely
differently in order to avoid reflection, and it was just a fluke
that it worked in 1.2?
Thanks,
Andy
(ns nbody
(:gen-class))
(set! *warn-on-reflection* true)
(definterface IBody
(^double x [])
(^double y [])
(^double z [])
(^double dist [other]))
(deftype Body [^{:unsynchronized-mutable true :tag double} x
^{:unsynchronized-mutable true :tag double} y
^{:unsynchronized-mutable true :tag double} z ]
IBody
(x [this] x)
(y [this] y)
(z [this] z)
(dist [this other]
(let [^Body nbody other
dx (- x (.x nbody)) ; first reflection warning here
dy (- y (.y nbody)) ; second here
dz (- z (.z nbody)) ; third here
dsq (+ (* dx dx)
(+ (* dy dy)
(* dz dz)))]
(Math/sqrt dsq))))
(defn -main [& args]
(let [b (Body. 0 0 0)]
(println "pos:" (.x b) (.y b) (.z b))))
--
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
--
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
--
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