Hi,

On Feb 9, 4:22 pm, Аркадий Рост <arkr...@gmail.com> wrote:

> For example:
>
> (ns exaple_class
>     (:gen-class))
>
> (defn -main [args*] (...do smth...))
> (defn -method_name1 [args*] (...do smth...))
> (defn- -method_name2 [args*] (...do smth...))
> (def -a 5)
>
> (defn fun1 [args*] (...do smth...))
> (defn- fun2 [args*] (...do smth...))
> (def b 5)
>
> As I understand, in this example we'll get java class. It's name test
> and it contains methods: main, method_name1, method_name2.

No. It just has a static method main (which is specially treated). To
make method_name1 and method_name2 you must declare so in the gen-
class clause.

(ns example.class
  (:gen-class
    :methods [[method_name1 [... arg types here ...] return type here]
              [method_name1 [... arg types here ...] return type here]
              #^{:static true} [some_static_method ....]]))

> What does it mean that method_name2 is declared as private?

The "methods" are just plain old clojure function. The real methods
are stubs which call these functions. So you can basically call the
method functions directly. If method_name2 is private this can only be
done from the same namespace. For (.method_name2 obj ...) form of
calling the private flag is not of interest and works from everywhere.

> Then what classes will contain functions fun1, fun2?

No class will contain those functions, because they are not declared
in the :gen-class clause.

> fun2 defined with defn- so it will be private, but for what does it
> mean?

See above for method_name2.

> Also is there difference beetwen declaration -a and b?

It's just a different name. Otherwise they will behave the same.

> what classes are they containing in?

No classes will contain -a or b. gen-class'd classes cannot contain
"fields". You can only specify a state (via :state in the :gen-class
clause). However the state can be a map, which can hold different
other values. However it is immutable. So if you want to modify the
state you have to wrap into a ref or atom.

See also: http://clojure.org/compilation

Hope this helps.

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