[Nickle]Type narrowing
Keith Packard
nickle@nickle.org
Mon, 29 Jul 2002 13:59:36 -0700
Around 20 o'clock on Jul 29, Carl Worth wrote:
> It seems to be that poly and union are functionally equivalent. (union
> defines a type that can hold a value of any type belonging to a set of
> types given in the union definition. poly is effectively a union with
> an unrestricted set of allowable types).
Almost, but not quite. Unions in nickle must be explicitly typechecked
anytime you use the value held within them while poly values are
only typechecked at runtime when interactive with stronger types.
At this point, you should treat 'poly' as a crutch for a weak language; we
need paramorphic polymorphism to solve most of the cases currently using
'poly', except of course where applications really do want only runtime
typechecking to match some existing semantics (like your FP experiments).
I was using unions to hold the list of types narrowed from poly, but that
really warped the internal use of unions. Using a proper separate
representation has removed most of the gore surrounding typechecking and
unions; removing 'null' types fixed most of the remaining ugliness.
-keith