[PRL] IOP and disjoint unions

Carl Eastlund carl.eastlund at gmail.com
Thu Apr 28 16:46:52 EDT 2005


On 4/28/05, Richard Cobbe <cobbe at ccs.neu.edu> wrote:
> > What's wrong with a separate interface for each variant?  In ML, you
> > have a separate type for each variant, and interfaces have a lot in
> > common with types.  Further, what's wrong with using instanceof checks
> > in place of ML's pattern matching or Scheme's constructor predicates?
> > And who said anything about interfaces being purely static entities?
> 
> First, do you really have a separate type for each variant in ML?

Let's look at lists:
type intList = Nil of unit | Cons of int * intList

Here we have a type for each variant (unit and int * intList) plus a
new type for the variant, so n+1 instead of just n, I was slightly
imprecise.  So what I was really getting at was Will's suggestion for
a parent interface with predicates and conversions, and child
interfaces for each specific member of the disjoint union.

--Carl



More information about the PRL mailing list