>
> (defn make-window [id]
>  {:tag ::window, :id id})
>
> (defn make-color-window [id color]
>  (assoc (make-window id)
>    :tag ::color-window
>    :color color))
>
> (derive ::color-window ::window)
>
> (defmulti describe-window :tag)
>
> (defmethod describe-window ::window [w]
>  (println "Window with ID" (:id w)))
>
> (defmethod describe-window ::color-window [w]
>  (println (:color w) "Window with ID" (:id w)))
>
> (let [w (make-color-window 24 "blue")]
>  (describe-window w))
> ;; => prints "blue window with ID 24"


In any fairly large UI system this would become tedious in no time and a hit
on readability.  For example consider building a UI system from scratch for
a JOGL game of even medium complexity in pure Clojure (scrollbars, views,
zoomable views, sprites, physics, icons, buttons, et al.). A higher level
abstraction is required.  I'm not arguing that the language needs to provide
it directly, but at least have the framework in place so that it can be done
via macros (which already is the case).

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