[MLton] an analysis to flatten refs into tuples

Matthew Fluet fluet@cs.cornell.edu
Mon, 17 May 2004 18:26:00 -0400 (EDT)

> The best fix I can think of is to modify the SSA IL so that we have a
> new type
> 	ConApp of Con.t
> where values of type "ConApp c" are those built by applying the
> constructor c.  We can then add ConSelect and ConUpdate expressions
> and can change case statements to include the (safe) downcast from the
> sum type to the variant type appropriate to each branch.  Then, the
> branches can do the selects and updates (safely) wherever they please.

Do you mean doing something like:

datatype t = A of int | B of int

L0: ...
    case x of A => LA | B => LB

LA(xa: ConApp A): ... a: int = ConSelect (xa, 0) ...

LB(xb: ConApp B): ... b: int = ConSelect (xb, 0) ...

Now the case statement doesn't do the implicit selects, but does do an
implicit copy.  Type checking the above certainly seems pretty

But, what is the type of z in the following?
  z = ConApp (A, #[0])
Would we require another coercion statement to lift z (as a ConApp A) to a
Datatype t?

BTW, whatever is done to the IL, then the knownCase pass will take a real