There is something I don't understand about Clojure. There are
multimethods (great), but I can't seem to find objects they can operate
on. I come to Clojure from a Common Lisp background, having done a fair
bit of CLOS programming. Mind you, I am not necessarily a fan of overly
complex object hierarchies. But still -- I've been trying and I just
can't seem to make objects in Clojure work.

>From what I read, the reasoning is that Clojure provides extremely
general multimethods where you have to define a dispatch function. On
the object side, there is metadata and you can do with it whatever you
want. But this seems to leave a gaping hole saying "fill me with an
object system". Is the goal for everyone to roll their own?

I'm against overusing objects, but there are things which quite
naturally map into the object-oriented paradigm. Let's take windowing
systems for example -- let's assume you have various kinds of windows,
each with its own unique attributes and attributes which are inherited
(e.g. a window-id attribute is common to all windows). I can't see how
you'd implement that in Clojure when you can't inherit structmap
attributes. How do I build my-special-window which is a kind of window
and also inherits window's window-id attribute? I know how to inherit
behavior, but there is behavior that requires data, and I have no idea
how to store and inherit that data. I looked at merge, but it seems you
can't merge structure basis objects.

Unfortunately, all discussion on Clojure polymorphism, multimethods and
objects that I could find seems to use overly simplified examples (it
really only shows that there are multimethods which can do multiple
dispatch on anything), and doesn't really help. Even Stuart Halloway's
beta "Programming Clojure" book has very simple examples that don't
inherit attributes, just use different type tags for the same
information.

--J.

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