[m-dev.] diff: fix bug with nested modules & intermod opt

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 2 19:32:14 AEDT 1998


On 02-Nov-1998, David Glen JEFFERY <dgj at cs.mu.OZ.AU> wrote:
> On 02-Nov-1998, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > compiler/termination.m:
> > 	Minor changes to reflect the above changes to data-structures;
> > 	in particular, use the new procedures defined in hlds_pred.m
> > 	instead of hard-coded tests.
...
> Generally, looks fine.
...
> I don't understand what's going on here [in termination.m], though. [...]
> Your log message just says you made changes to termination.m to
> reflect the changes in the data structures. Those last two changes seem
> to be changing the behaviour.

The code in termination.m was basically a three-way test, with the
third case being a "this should not happen" case:

	(
		( ImportStatus = exported
		; ImportStatus = local
		; ImportStatus = pseudo_exported
		)
	->
		... handle case when defined in this module ...
	;
		( ImportStatus = imported
		; ImportStatus = opt_imported
		; ImportStatus = pseudo_imported  % should this be here?
		)
	->
		... handle case when defined in a different module ...
	;
		% ( ImportStatus = abstract_imported
		% ; ImportStatus = abstract_exported
		% ),
		error("this case should never happen")
	).

When I changed the code to use the higher-level interface,
I found there was no longer any need to consider each different
import status; my new code looked like this:

	( 
		status_defined_in_this_module(ImportStatus)
	->
		... handle case when defined in this module ...
	;
		... handle case when defined in a different module ...
	).

I didn't change the overall behaviour of the compiler -- locally I changed
the behaviour in the "cannot happen" case, but the "cannot happen"
case cannot happen, so the overall behaviour is unchanged ;-)

That change did remove some error detection which could potentially be useful.
But keeping the error detection would require breaking the abstraction --
detecting the error requires noticing inconsistencies in exactly
those details which the higher-level interface abstracts away.
Previously the error detection here was useful, because e.g. adding
a new import status would require modification to this code, and the
runtime check will help to prevent future from forgetting that modification.
But now adding a new import status will not require modification
to this code, so there's very little advantage in keeping the error
detection there.

Does that explain things?

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list