Andrew Wagner a écrit :
> So there's a different macro analogous to "String." for a bunch of 
> different classes, and it doesn't work for arbitrary classes?

It works for arbitrary classes. Any symbol that ends with a dot 
macroexpands to a 'new form.
=> (macroexpand '(AndrewWagner.))
(new AndrewWagner)

In this sense, String. is a macro (since it macroexpands) but there's no 
defmacro statement, it's a special case of macroexpansion -- just like 
.method, see:
=> (macroexpand '(.bar foo))
(. foo bar)

In both case it's not a special form (because special-symbol? returns 
false) nor a readermacro (if you try quoting them at the repl, they 
won't expand).

hth

Christophe

> On Tue, Jun 9, 2009 at 2:55 AM, Konrad Hinsen 
> <[email protected] <mailto:[email protected]>> wrote:
>
>
>     On 08.06.2009, at 21:59, Andrew Wagner wrote:
>
>     > Just to be clear, is (String.) a macro? I thought it was just a
>     > special form.
>
>     Let's ask Clojure:
>
>            (macroexpand-1 '(String.))
>     ->      (new String)
>
>     So it's a macro. The only difference between a macro and a special
>     form is that a macro expands into something, whereas a special form
>     is handled directly by the compiler. This also means that the
>     distinction is implementation-dependent: Clojure 1.1 could very well
>     implement (String.) as a special form, or implement new as a macro.
>
>     Konrad.
>
>
>
>
>
> >


-- 
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.blogspot.com/ (en)



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

Reply via email to