> (...)
> This is perfectly possible, although not necessarily desirable.
>
> (ns com.example.MyClass
> (:gen-class
> :state state
> :init init
> :methods [[getMyIntField [] Integer]
> [setMyIntField [Integer] Void/TYPE]]))
>
> (defn -init
> [x]
> [[] (ref x)])
>
> (defn -getMyIntField
> [this]
> (-> this .state deref))
>
> (defn -setMyIntField
> [this x]
> (dosync (ref-set (.state this) x)))
Well, much more important for me is the ability to declare a class
with some *fields*. Methods (functions) using these fields can be
implemented in Clojure (the class doesn't need to be used from Java).
So how can I implement in Clojure the following code?
class MyClassA
{
int myIntField;
}
class MyClassB extends MyClassA
{
int myNewIntField;
}
> (...)
> You can implement multiple inheritance with multimethods.
> (...)
I'm not asking about multiple inhertiance of methods. I'm asking about
multiple inheritance of *fields*.
But I could live without it eventually. I do when I'm using Java.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---