On Sat, Nov 15, 2008 at 8:27 PM, lsmith <[EMAIL PROTECTED]> wrote:
>
> I've just started playing around with clojure, and can't quite make
> out how the (.    special form works.
>
> For example,
> (. javax.swing.JOptionPane (showMessageDialog nil "Hello World"))
> seems to work just fine, but
> (. System.out (println "wtf"))
> does not. Only (.. System out (println "wtf")) does what I want.
>
> Any idea what's going on?

The problem is that Java uses dots to separate different things:
nested package levels, package and classname, nested class levels,
class and static field/method name, instance and field/method name.
Some of these map to dots in Clojure, but some do not.

In the Java expression java.lang.System.out, "System" is the class
name, but "out" is a static field name.  In Clojure it is
java.lang.System/out

Java: java.rmi.Naming.ParsedNamingURL
Here "Naming" is a class, so "ParsedNamingURL" is a nested class,
spelled in Clojure like this:
java.rmi.Naming$ParsedNamingURL

Java: "foo".substring(1)
Instance method and field references in Clojure put the dot elsewhere,
either (. "foo" substring 1) or preferably (.substring "foo" 1)

Putting those together, as Stephen Gilardi said, you get (.println
System/out "get it done")

--Chouser

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to