Mark Volkmann a écrit :
> What are some benefits of allowing two ways of doing the following?
>
> There are two ways to access constants in a Java class.
> (. java.util.Calendar APRIL)
> java.util.Calendar/APRIL
>
> There are two ways invoke a static method in a Java class.
> (. Math pow 2 4)
> (Math/pow 2 4)
>
> There are two ways to invoke a constructor to create a Java object.
> (def calendar (new GregorianCalendar 2008 3 16))
> (def calendar (GregorianCalendar. 2008 3 16))
>
> There are two ways invoke an instance method on a Java object.
> (. calendar add Calendar/MONTH 2)
> (.add calendar Calendar/MONTH 2)
>
> It seems that in each case the second way is preferred. Why not get
> rid of the first way?
>   
The first way makes macros easier to write.

eg:
  `(new ~a-class) instead of (list (symbol (str (name a-class) \.)))

The second way is just "syntax" sugar:
user=> (macroexpand-1 '(Foo.))
(new Foo)

Christophe


--~--~---------~--~----~------------~-------~--~----~
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 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to