Hi,

Am 15.04.2009 um 14:04 schrieb Konrad Hinsen:

As an example, take algebraic data types as defined in
clojure.contrib.types. A simple binary tree structure can be defined
with

(defadt ::tree
  empty-tree
  (leaf value)
  (node left-tree right-tree))

Values of this type are represented as maps in which the value
associated with :clojure.contrib.types/tag is the constructor (`empty-
tree, `leaf, or `node), with the :type in the metadata being ::tree.
This double labelling makes sure that all tree values are recognized
as being of the same type in dispatching, but also that equality
tests take into account the constructor in addition to its arguments.

Maybe I'm missing something, but we can't you just derive
::leaf, ::empty-tree and ::node from ::tree? You can use ::tree in
dispatch values, but the map still contains the constructor...

Sincerely
Meikel

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to