Hi,

Am 09.02.2010 um 18:10 schrieb Аркадий Рост:

> Oh...So to make methods I must declare them in gen-class clause and if
> some function wasn't include in gen-class clause, it wouldn't be a
> method even if it had a prefix from gen-class clause.
> I mean:
> (ns example.class
>  (:gen-class
>   :prefix pre-
>   :methods [[method_name1 [... arg types here ...] return type
> here]]))
> 
> (defn -main [args*] (...do smth...))
> (defn pre-method_name1 [args*] (...do smth...))
> (defn pre-method_name2 [args*] (...do smth...))
> 
> In example: method_name1 is a method because it is included in gen-
> class clause, -method_name2 is clojure function.

In fact both are clojure functions. However you can call (.method_name1 obj) 
but not (.method_name2 obj).

> But what about main?
> Is it a function(not method) because prefix was changed or not?

main is special. You can tell whether to generate a static main method via 
":main true" or ":main false" in the :gen-class clause. true is the default. So 
in you example a main method will be generated, but it can't be used, because 
there is no function called pre-main. -main is a normal clojure function (as 
would be pre-main if it was defined).

> And what function's names can be used to declare class method without
> including them to gen-class clause? (main and what else?)

Only main is of that sort. And methods from interfaces and super classes don't 
have to be declared. In fact they are not allowed to be declared.

Sincerely
Meikel

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

Reply via email to