On 13/05/2011, at 2:21 PM, David Nolen wrote:

> - instance? or custom predicate matches done w/ if

I did quite a bit of this in the context of a Smalltalk implementation. One of 
the key features is fast type testing. I note in your example case you are 
relying on an id generic to provide the type tags that are type-hierarchy 
aware. As long as your type tests are wrt a tree, rather than a graph, then 
maintaining a DFS number on the tree gives very cheap subclass testing. In a 
dynamic language you have to maintain that number in the face of changes to the 
tree, which can be optimised in various ways such as an initial sparse 
allocation, with an increase in sparseness as you note parts of the tree being 
updated dynamically. Also you need to allow your dispatch functions to either 
be updated in response to tree changes (not a great idea) or to use a level of 
indirection so that you reference the type tree in some way in your test and 
get the appropriate id range on the fly (and, of course, maintain the bounding 
pair of ids in the tree for each node).

Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

If you pick up a starving dog and make him prosperous, he will not bite you. 
This is the principal difference between a man and a dog.
  -- Mark Twain


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