Globals...

Daniel Wang danwang@cs.princeton.edu
13 Feb 2000 19:39:07 -0500


I'm in the process of hacking up the clousre converter, it's much easier
than I thought. In anycase, one thing I'm not clear about is what role
globals play in the big scheme of things. Are they very important? 
Can someone explain the following comment... in particular the reference to
the coercions.

In the Accum structure of closure-convert.fun

      fun done(T{globals, functions}) =
	 {functions = functions,
	  globals =
	  let
	     val exp =
		(* Must shrink because coercions may be inserted at constructor
		 * applications.  I'm pretty sure the shrinking will eliminate
		 * any case expressions/local functions.
		 * The "NoDelete" is because the shrinker is just processing
		 * globals and hence cannot safely delete a variable that
		 * has no occurrences, since there may still be occurrences in
		 * functions.
		 *)
		Cps.shrinkExpNoDelete
		(Cexp.toExp(Cexp.lett
			    {decs = AL.toList globals,
			     body = Cexp.tuple{exps = [], ty = Ctype.unit}}))
	     val decs = Cps.Exp.decs exp
	  in 
	     List.map(decs,
		      fn Cdec.Bind b => b
		       | _ => Error.bug "globalization produced a non binding")
	  end}