First example tries to access a public static field in the Math class. Second example calls the static member function of the Math class.
The difference is in the missing set of parenthesis. A static field or member function is attached to the class, not to a specific object and can be accessed through the class itself. Hence the / notation. On the other hand, (.addListener x ...) refers to the member fn addListener of the given object x. You will rarely find Java object specific public fields directly accessible, most of the time you need to use a getter to access them, hence the profusion of .getXzzz when you look at interop code. Static fields attached to a class are most of the time immutable, they are a way to make constants public and avoid the getter wrapper syndrom. Last thing, a class can define classes so you may need to access Aclass$Bclass/field to get access to a class static field defined within a class. This does not apply to an object of class B, the usual (.memberFn object ...) would still apply assuming you are handed an object created from an inner class. Luc P. > It almost certainly has something to do with my abysmal ignorance about > things Java, but I don't understand this difference: > > (1) > user> (map Math/sqrt [5 6 16]) > > Unable to find static field: sqrt in class java.lang.Math > [Thrown class java.lang.RuntimeException] > > (2) > user> (map #(Math/sqrt %) [5 6 16]) > (2.23606797749979 2.449489742783178 4.0) > > Thanks for helping me understand. > --Larry > > -- > 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 > -- Softaddicts<lprefonta...@softaddicts.ca> sent by ibisMail from my ipad! -- 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