Nice, I have been looking for something like this to experiment with.

Suggestions on syntax: It would be much nicer to use and more idiomatic if 
the method name came first, e.g.

(method some-object arg1 arg2)

This would bring many benefits: you could use the standard "->" syntax, you 
can "apply" a method, it will fit much better when composed with Clojure 
library functions etc. You could also potentially use any associative data 
structure as your object type. You could also potentially have special 
handling for null object values, default implementations in case of missing 
methods etc.

This suggests to me that it would be a better design if each method was 
defined as a function that looked up the specific implementation in the 
prototype object and called it. You could use a macro to declare the 
function, and possibly even a default value, e.g.

(def mymethod 
  (prototype-fn [obj arg1 arg2] 
    :default (do-something-with arg1 arg2)))

When would expand into something like:

(defn mymethod [obj arg1 arg2]
  (if-let [method (:$mymethod obj)]
    (method obj arg1 arg2)
    (do-something-with arg1 arg2)))

Obviously, this means that you need to explicitly declare prototype 
methods. But I think this is a good idea anyway: it ensures a bit more 
discipline and testability (which is often the biggest problem in 
prototype-based systems.....)

On Monday, 11 February 2013 04:21:58 UTC+8, eduardoejp wrote:
>
> Just a simple toy project I made moments ago...
> https://github.com/eduardoejp/jormungandr
>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to