[PRL] IOP and disjoint unions

Dave Herman dherman at ccs.neu.edu
Thu Apr 28 15:26:25 EDT 2005


When you're writing OO code in an interface-oriented way, how do you 
encode disjoint unions? The typical way to do it in class-based 
languages is to encode the variants as subclasses of a base class.

But in IOP this would entail a separate interface for each variant 
(blech). Worse, variants of disjoint unions in ML-like languages are 
distinguished with dynamic tags, not static types; this would suggest a 
dynamic interface check, which contradicts the intuition of interfaces 
as being static.

OTOH, if you disregard the IOP style and make the client code test for 
specific classes, then that prevents you from being able to change the 
implementation of the disjoint union later.

Dave



More information about the PRL mailing list