Hi clojure developers!

I recently wrote an alternative datatype system for a project of mine,
because requirements were a little odd and I couldn't find anything
appropriate.

My questions are:
1) Was this necessary at all? Can my requirements be fulfilled with
off-the-shelf clojure libraries or components? Requirements include
the ability to merge objects as shown below.
2) Do you think this system would be useful to the clojure community?
Should I clean it up and publish it?

The best way to show how it works is with an example:

; This create a product "class". The "mandatory" function
; returns a special value which throws an
; exception when it's read.
; Sort of like a pure virtual method.
(defobject :product []
  :name (mandatory)
  :price (mandatory)
  :warranty (mandatory))

; PC's have 1 year of warranty by default in our shop
(defobject :pc [:product]
  :cpu (mandatory)
  :ram (mandatory)
  :warranty 1)

; Mobiles instead get 3
(defobject :mobile [:product]
  :battery-idle-time (mandatory)
  :warranty 3)

; This FAILS: the system tries to inherit the :warranty property
; from both parents but a conflict occurs (because the values are
different)
(defobject :smartphone [:pc :mobile])

; We must override the :warranty property. This works:
(defobject :smartphone [:pc :mobile]
  :warranty 2)

; Then we can create an "instance"...
(defobject :zamzun-universe [:smartphone]
  :cpu :z80
  :ram "1GB"
  :battery-idle-time "300h")

; ...and use it
(fetch (object :zamzun-universe) :warranty)
; -> 2

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