On Feb 1, 7:22 pm, David Nolen <dnolen.li...@gmail.com> wrote:
> I've changed the name of my project since that was a joke 
> anyway.http://github.com/swannodette/spinoza/tree/master
>
> Spinoza isn't just for people who want object oriented behaviors.  It's also
> for anyone who plans on instantiating many structs.  Spinoza's make-instance
> macro automatically orders your key/values and uses struct not struct-map.
>
> (defclass shape [object]
>   (:position [0 0]))
>
> (defclass rect [shape]
>   (:position [5 5])
>   :width
>   :height)
>
> (time (dotimes [x 1000000]
> (make-instance rect :height 100 :width 150)))
>
> > ~280ms
>
> (defstruct rect-struct :tag :position :width :height)
> (time (dotimes [x 1000000]
> (struct-map rect-struct :tag ::rect :position [50 50] :width 100 :height
> 190)))
>
> > ~800ms
>
> Also, it is now available under an MIT license, feel free to fork, send
> patches at will etc.


I'm still quite interested in this project, and I'm tempted to try
rewriting a subsystem in my own main project with it, but in the
course of developing some behavior that I needed, I went off in a
slightly different quasi-object-like direction. If I were going to add
something to Spinoza, it would be eql specializers.

I'm not going to add anything to Spinoza, though, at least not right
now; instead, I'm going to keep working on my own model/protocol/thing
subsystem. Similar to Spinoza, it uses maps to represent objects;
objects are called 'things'. A thing has a 'model' and a 'protocol'.
The model determines what fields the thing has, and whether there are
any type restrictions on the values; the protocol determines what
operations (that is, what multifunctions) work on the thing.

I don't argue that this model is better than what you're doing with
Spinoza, but for years (see 
http://www.mactech.com/articles/frameworks/8_2/Protocol_Evins.html
from 1994) I've wanted an object model that explicitly separates
structure from protocol, and since I partially built one in order to
satisfy a need I had in a larger project, I think I'll push ahead with
it a bit to see whether it's worthwhile.

If I were going to add one thing to my own model/protocol/thing
subsystem--or add one thing to Clojure to support it--it would be
predicate dispatch. Who knows? Maybe I will, if I decide that I want
it badly enough.



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