[m-dev.] Ye Olde Subtyping Proposal

David Overton dmo at cs.mu.OZ.AU
Tue Nov 12 09:41:42 AEDT 2002


On Tue, Nov 12, 2002 at 02:45:16AM +1100, Fergus Henderson wrote:
> > 	2) manually change all of the library preds/funcs to be
> > 	   polymorphically moded, except where the change would be
> > 	   unsafe.
> 
> (2) has been proposed before, but has not been applied because it
> significantly slows down compilation of programs that use the library :-(
> 
> Of course making them all implicitly polymorphically moded
> would have the same problem.

No, one of the benefits of "implicit" polymorphic modes is that when you
are doing mode analysis of the polymorphic procedure itself, you can
treat all implicitly polymorphic insts as just `ground' (or whatever
inst it is constrained to be a subinst of).

E.g. the example I tried was converting tree234.m to explicitly use
polymorphic modes.  That required defining an inst

	:- inst tree234(K, V)	--->
		empty
	;	two(K, V, tree234(K, V), tree234(K, V))
	;	three(K, V, K, V, tree234(K, V), tree234(K, V), tree234(K, V))
	;	four(K, V, K, V, K, V, tree234(K, V), tree234(K, V),
			tree234(K, V), tree234(K, V)).

which was then used in the instmap for nearly every variable of type
tree234(K, V), whereas previously, the insts of these trees could be
described much more efficiently (but less precisely) using just `ground'.
Using implicit polymorphism, where it can be proved to be safe using the
"theorems for free" approach, allows you to continue using `ground'
_inside_ the procedure.

This extra complexity is what slowed down mode analysis.  IIRC, for
tree234.m the total compilation time increased by approx a factor of 6.


David
-- 
David Overton                  Uni of Melbourne     +61 3 8344 9159
dmo at cs.mu.oz.au                Monash Uni (Clayton) +61 3 9905 5779
http://www.cs.mu.oz.au/~dmo    Mobile Phone         +61 4 0337 4393
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list