forwarded message from Henry Cejtin

Stephen Weeks sweeks@intertrust.com
Tue, 10 Oct 2000 15:37:01 -0700 (PDT)


Received: from maguro.epr.com ([198.3.162.27]) by exchange.epr.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21)
	id TV5JRBK0; Tue, 10 Oct 2000 15:19:16 -0700
Received: from magrathea.epr.com (firewall-user@magrathea.epr.com [198.3.160.1])
	by maguro.epr.com (8.9.3/8.9.3) with ESMTP id PAA03901
	for <sweeks@intertrust.com>; Tue, 10 Oct 2000 15:22:26 -0700 (PDT)
Received: (from uucp@localhost) by magrathea.epr.com (8.9.3/8.7.3) id PAA21047 for <sweeks@intertrust.com>; Tue, 10 Oct 2000 15:22:12 -0700 (PDT)
Received: from nodnsquery(199.249.165.245) by magrathea.epr.com via smap (V5.5)
	id xma021018; Tue, 10 Oct 00 15:22:09 -0700
Received: (from henry@localhost)
	by syzygy.clairv.com (8.9.3/8.9.3) id RAA32337
	for sweeks@intertrust.com; Tue, 10 Oct 2000 17:22:08 -0500
Message-Id: <200010102222.RAA32337@syzygy.clairv.com>
From: Henry Cejtin <henry@sourcelight.com>
To: sweeks@intertrust.com
Subject: Re: MLton's closure conversion
Date: Tue, 10 Oct 2000 17:22:08 -0500

Interesting.  Note, one thing we can do is to delay any selection (or some of
the selections) until you get to a split in the control flow such  that  some
of  the  environment  is  dead  in one of the branches.  Since everything was
flattened out already in the F2 example (non-curried case) this wouldn't help
there,  I  could  imagine big improvements otherwise.  I.e., in one branch of
that all the environment is dead, and in the other all of it is  alive:  thus
you  would  just  delay  all selects (eliminating them from the fast case and
delaying further in the slow case).

The general problem of currying also is interesting.  We tend not to use  it,
so  it  doesn't  show  up  very much in our code.  We could transform curried
functions into curried calls to uncurried ones.  I.e., replace

    fun f a b c =
           if a > 0
              then f (b + c) x (f y z w)
           else 17

to
    fun f' (a, b, c) =
           if a > 0
              then f' (b + c, x, f' (y, z, w))
              else 17

    fun f a b c = f' (a, b, c)

and then use the inliner to convert the f calls to f' in the case that it  is
completely called.