[m-rev.] For review: State Variables

Simon Taylor stayl at cs.mu.OZ.AU
Tue Jun 11 17:29:23 AEST 2002


On 07-Jun-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Index: make_hlds.m
> ===================================================================
> @@ -16,6 +16,9 @@
>  % super-homogenous form, and introduce implicit quantification.
>  % 
>  % XXX we should record each error using module_info_incr_errors.
> +%
> +% XXX For state variables, we should allow quantifiers around if-then-else
> +% expressions.

Just to be clear, this needs to be done immediately.

> @@ -6901,7 +7058,17 @@
>  	% that each unification gets reduced to superhomogeneous form.
>  	% It also gets passed a `arg_context', which indicates
>  	% where the terms came from.
> +
>  	% We never insert unifications of the form X = X.
> +	% If ForPragmaC is yes, we process unifications of the form
> +	% X = Y by substituting the var expected by the outside environment
> +	% (the head variable) for the variable inside the goal (which was
> +	% created just for the pragma_c_code goal), while giving the headvar
> +	% the name of the just eliminated variable. The result will be
> +	% a proc_info in which the head variables have meaningful names
> +	% and the body goal is just a pragma C code. Without this special
> +	% treatment, the body goal will be a conjunction, which would
> +	% complicate the handling of code generation for nondet pragma C codes.
>  
>  :- type arg_context
>  	--->	
> @@ -6919,80 +7086,89 @@
>  		).
>  
>  :- pred insert_arg_unifications(list(prog_var), list(prog_term),
> -		prog_context, arg_context, hlds_goal, prog_varset,
> +		prog_context, arg_context, bool, hlds_goal, prog_varset,
>  		hlds_goal, prog_varset, transform_info, transform_info,
> -		io__state, io__state).
> -:- mode insert_arg_unifications(in, in, in, in, in, in, out,
> -		out, in, out, di, uo) is det.
> +		svar_info, svar_info, io__state, io__state).
> +:- mode insert_arg_unifications(in, in, in, in, in, in, in, out,
> +		out, in, out, in, out, di, uo) is det.

This undoes a change I committed last week. Please go over your diff
thoroughly to make sure there are no other stray changes.

> @@ -7217,22 +7443,25 @@
>  	%	NewVar3 = A3.
>  	% In the trivial case `X = c', no unravelling occurs.
>  
> -unravel_unification(term__variable(X), RHS,
> -			Context, MainContext, SubContext, VarSet0, Purity,
> -			Goal, VarSet, Info0, Info) -->
> -	{ RHS = term__functor(F, Args, FunctorContext) },
> +unravel_unification_2(term__variable(X), RHS,
> +		Context, MainContext, SubContext, VarSet0, Purity,
> +		Goal, VarSet, Info0, Info, SInfo0, SInfo) -->
> +	{ RHS = term__functor(F, Args0, FunctorContext) },
> +	{ Args1 = expand_bang_state_var_args(Args0) },

You're still not doing this consistently. For example, !X is not
expanded in `aditi_insert(p(!X), DB, DB)' or `X ^ field(!X) := Value'.

It might be better to expand !X only in predicate clause heads and
predicate calls (!X doesn't really make sense in function calls).

> +:- func reconciled_svar_infos_dots(prog_varset, svar_info, svar, svar_info) =
> +		svar_info.
> +
> +reconciled_svar_infos_dots(VarSet, SInfoX, StateVar, SInfo0) = SInfo :-
> +	( if
> +		DotX = SInfoX ^ dot ^ elem(StateVar),
> +		Dot0 = SInfo0 ^ dot ^ elem(StateVar)
> +	  then
> +	  	NameX = varset__lookup_name(VarSet, DotX) `with_type` string,
> +	  	Name0 = varset__lookup_name(VarSet, Dot0) `with_type` string,
> +		compare(RDot, NameX, Name0),
> +		(
> +			RDot  = (<),
> +			SInfo = ( SInfo0 ^ dot ^ elem(StateVar) := Dot0 )
> +		;
> +			RDot  = (=),
> +			SInfo = SInfo0
> +		;
> +			RDot  = (>),
> +			SInfo = ( SInfo0 ^ dot ^ elem(StateVar) := DotX )
> +		)
> +	  else
> +	  	SInfo = SInfo0
> +	).

Does this work? For example, `STATE_VAR_X_2' will compare greater
than `STATE_VAR_X_10'.

Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list