[m-dev.] for review: support reordering conjunctions in mode inference

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Dec 20 18:36:03 AEDT 2000


On 20-Dec-2000, David Overton <dmo at cs.mu.OZ.AU> wrote:
> On Wed, Dec 20, 2000 at 05:01:38AM +1100, Fergus Henderson wrote:
> > 
> > Change mode inference so that it supports reordering of conjunctions.
> > 
> 
> [...]
> 
> > 
> > compiler/mode_info.m:
> > 	Add procedures `set_pred_id' and `set_proc_id'; these are used
> > 	by mode_errors.m to print out
> 
> Is something missing here?

Yes.  The log message should read

        ... to print out the error message for the callee
	when printing messages for `mode_error_in_callee' errors.

> > +++ compiler/modes.m	2000/12/19 16:33:44
...
> > -		inst_matches_initial(VarInst, Inst, Type, ModuleInfo0,
> > -			ModuleInfo, Subst0, Subst1)
> > +		(
> > +			NeedExactMatch = no,
> > +			inst_matches_initial(VarInst, Inst, Type, ModuleInfo0,
> > +				ModuleInfo, Subst0, Subst1)
> > +		;
> > +			NeedExactMatch = yes,
> > +			inst_matches_final(VarInst, Inst, Type, ModuleInfo0),
> > +			ModuleInfo = ModuleInfo0,
> > +			Subst1 = Subst0
> > +		)
> 
> If there are any inst variables in the mode of the callee, these will
> be ignored here if `NeedExactMatch = yes'.  This is not currently a
> problem since 
> 
> 	1. `NeedExactMatch = yes' only if we are doing mode inference
> 	    on the callee; and
> 	2.  mode inference currently will not infer polymorphic modes.
> 
> However, either of these conditions may change in the future -- so an XXX
> comment here warning of that would be a good idea.
> 
> A more robust (although less efficient so you probably don't want to
> do it) solution would be to call `inst_matches_initial' in the
> `NeedExactMatch = yes' branch to calculate `Subst1' as well as calling
> `inst_matches_final' to do the check that this is not an implied mode.

I've added the following comment (after the `Subst1 = Subst0' line):

                        % WARNING:
                        % The code above (Subst1 = Subst0) assumes that there
                        % are no inst variables in the mode of the callee.
                        % Currently this will always true, since
                        % `NeedExactMatch' will be `yes' only if we are
                        % doing mode inference on the callee, and mode
                        % inference currently will not infer polymorphic modes.
                        % But that assumption might not always hold in future.
                        % An alternative would be to call inst_matches_initial
                        % here too, just to calculate the inst substitution.
                        % But that would be less efficient, so (at least
                        % for now) we don't do it.

> Apart from these comments, this change looks fine.  Thanks Fergus.

Great, thanks for the review.  If there are no other review comments,
then I'll go ahead and commit it sometime in the next few days
(on the main branch only, not the version-0_10_x branch).

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