[m-dev.] for review: add parsing/storing of assertions

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Jul 8 20:35:10 AEST 1999


On 08-Jul-1999, Peter Ross <petdr at cs.mu.OZ.AU> wrote:
> +++ make_hlds.m	1999/07/08 09:43:11
...
> +transform(Subst, HeadVars, Args0, Body, VarSet0, Context, IsAssertion,
> +		Goal, VarSet, Warnings, Module0, Module, Info0, Info) -->
>  	transform_goal(Body, VarSet0, Subst, Goal1, VarSet1, Info0, Info1),
>  	{ term__apply_substitution_to_list(Args0, Subst, Args) },
>  	insert_arg_unifications(HeadVars, Args, Context, head, no,
>  		Goal1, VarSet1, Goal2, VarSet2, Info1, Info),
>  	{ map__init(Empty) },
> +		
> +		%
> +		% Currently every variable in an assertion must be
> +		% explicitly quantified, as it has not been determined
> +		% what the correct implicit quantification should be for
> +		% assertions.
> +		%
> +	(
> +		{ IsAssertion = yes }
> +	->
> +			% Use Goal1, since HeadVar__* not yet
> +			% introduced.
> +		{ quantification__goal_vars(Goal1, Unquantified) },
> +		{ set__to_sorted_list(Unquantified, ProblemVars0) },
> +
> +			% The Args are implicitly universally
> +			% quantified.
> +		{ term__term_list_to_var_list(Args, ArgVars) },
> +		{ list__delete_elems(ProblemVars0, ArgVars, ProblemVars) },
> +
> +		{ list__length(ProblemVars, L) },
> +		(
> +			{ L > 0 }
> +		->
> +			prog_out__write_context(Context),
> +			(
> +				{ L = 1 }
> +			->
> +				io__write_string("Error: the variable `")
> +			;
> +				io__write_string("Error: the variables `")
> +			),
> +			io__write_list(ProblemVars, ",", write_var(VarSet)),
> +			io__write_string("' were not explicitly quantified.\n"),
> +			{ module_info_incr_errors(Module0, Module) }
> +		;
> +			{ Module = Module0 }
> +		)
> +
> +	;
> +		{ Module = Module0 }
> +	),
>  	{ implicitly_quantify_clause_body(HeadVars, Goal2, VarSet2, Empty,
>  				Goal, VarSet, _, Warnings) }.

I think it would be a good idea to put that new code in a separate predicate.

Apart from that, this change (not including the documentation) looks fine.

I'll review the documentation separately.

-- 
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.
--------------------------------------------------------------------------
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