Ummm.... some of these thing DON'T map to Clojure.
I'd suggest you check out Rich's videos here:
http://blip.tv/file/982823
Anyway, as to how you would solve some of these problems in Clojure...
Static methods you get for free, because everything is a function in
Clojure.
Singletons aren't really required, because using a keyword generally
gets the same effect. You can also use a memoize function to prevent
expensive things being created more than once.
As far as Inheritance & Interfaces are concerned... well, uh... those
generally aren't used in Clojure. Personally, I use a lot of maps
where I used to use objects. I've found that I like my code better
now.
Others might have some other ideas on how to com from Java to Closure.
Sean
On Dec 12, 8:13 am, ajay gopalakrishnan <ajgop...@gmail.com> wrote:
> Hi,
>
> I come from a OOPS (Java) world and I am used to Singletons, Inheritance,
> Statics, Interfaces etc.
> I am reading the Programming Clojure book and I understand multi-methods and
> when it is used.
> But I am still not able to see how to achieve the effects of Singletons,
> Inheritance, Statics, Interfaces etc. in Clojure. If the book explains it
> somewhere, I would be glad to get a pointer to that too.
> When I say "achieve the effects" , I am not asking if there is a way to
> define a Singleton class etc. I am asking that if the design in my head has
> all these things, how would I translate that into Clojure (some way or the
> other) or what modifications would need to be made to my design (in my head)
> to able to directly write it in Clojure terms.
>
> Thanks,
> Ajay G.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--
--
"an abuse of macros?"
HAHAHA you are funny Laurent :-)
Here's an example of it in use -
http://s-expressions.com/2009/12/10/frumios-a-silly-object-system-for-clojure/
Obviously one wouldn't use it in a real production system (one would
use multi-methods etc. instead), but it's fun to see that Clojure is
powerful enough to implement something like this in ~70 lines of code.
More importantly, it shows that if you use something like this OO
system which gives you most of what Java/C++ gives you in terms of
traditional OO, you're actually limiting yourself. Of course, you
could expand this into a full blown CLOS-style object system....