Mark, > Here's a nice use of OCaml's casts to provide what can be viewed as an > open dynamic type (except that variant tags -- called brands here -- > are created at run time). There are ways of implementing such a dynamic type without using unsafe type casts (i.e. Obj.magic). I have attached a file containing two sample implementations. The first one generates exceptions dynamically and uses them as tags. The fact that they are exceptions is irrelevant; what matters is the ability to generate new tags at runtime. Unfortunately, this piece of code isn't accepted by O'Caml, because it doesn't recognize the type variable 'a in the exception declaration as bound by the preceding type annotation. The second one uses references as temporary buffers for data exchange. The idea was posted a while ago on this mailing list, but I couldn't find the exact reference. Instead of being tagged, a value is encoded within a function whose effect is to write the value into a reference. The second implementation is interesting, because it makes it easy to see why one shouldn't create polymorphic brands: brands *are* references in this approach. -- François Pottier Francois.Pottier@inria.fr http://pauillac.inria.fr/~fpottier/