[m-dev.] for review: record syntax [2]

David Glen JEFFERY dgj at cs.mu.OZ.AU
Fri Jan 7 16:06:08 AEDT 2000


On 07-Jan-2000, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > > Index: compiler/typecheck.m
> > > ===================================================================
> > > RCS file: /home/mercury1/repository/mercury/compiler/typecheck.m,v
> > > retrieving revision 1.268
> > > diff -u -u -r1.268 typecheck.m
> > > --- typecheck.m	1999/12/08 09:44:56	1.268
> > > +++ typecheck.m	1999/12/20 04:00:07
> > 
> > > +	%
> > > +	% For a field access function for which the user has supplied
> > > +	% a declaration but no clauses, add a clause
> > > +	% 'foo:='(X, Y) = 'builtin foo:='(X, Y).
> > > +	%
> > > +:- pred maybe_add_default_field_access_clauses(module_info,
> > > +		pred_info, pred_info).
> > > +:- mode maybe_add_default_field_access_clauses(in, in, out) is det.
> > 
> > It seems a bit weird to be doing this as part of typecheck. Couldn't it be
> > done earlier?
> 
> Possibly. It needs to be done after the clauses are added, and it
> seems a little wasteful to add an extra pass over all pred_ids just
> for that.

I guess so. I'm happy for it to remain where it is if it otherwise would mean
adding an extra pass.

> Estimated hours taken: 60
> 
> Implement syntax for getting and setting fields of constructors.
> 
> compiler/make_hlds.m:
> 	Add information about field definitions to the module_info.
> 
> 	Check that user-defined field access functions for exported
> 	fields are also exported, otherwise predicates in other modules
> 	could use a different method to access a field than predicates
> 	in module defining the field.
> 	Add a `predicate preds_add_implicit_report_error' to allow that check
> 	to be performed for functions which are added to the module_info
> 	by some means other than a `:- func' declaration.
> 
> 	Parse field access goals and expressions.
> 
> 	Add predicates `insert_arg_unifications_with_supplied_contexts',
> 	and `append_arg_unification', which allow more control over
> 	the contexts given to the added unifications. These are
> 	useful because the field value for an update is really an
> 	argument of the inner-most update function call, while the
> 	input term is an argument of the outer-most function call.
> 
> compiler/prog_io_dcg.m:
> 	Allow DCG goals of the form `:=(DCGArg)', which unifies `DCGArg'
> 	with the output DCG argument, ignoring the input DCG argument. 
> 	The rationale for this change is that if we have convenient syntax
> 	for updating parts of a DCG argument, we should also have convenient
> 	syntax for updating the whole DCG argument.
> 
> compiler/typecheck.m:
> 	Add a default clause for field access functions for which
> 	the user has supplied type and mode declarations but no
> 	clauses.
> 
> 	Typecheck field access function calls.
> 
> 	Use higher-order code to remove some duplication of code
> 	to write out comma separated lists of error descriptions.
> 
> compiler/post_typecheck.m:
> 	Expand field accessor goals into the equivalent unifications.
> 	They are expanded inline rather than generating new get and set
> 	predicates for field name to avoid having to work out how to mode
> 	the generated predicates.
> 
> 	Remove an unnecessary goal traversal to qualify function
> 	calls and constructors. That code is now called from purity.m.
> 
> compiler/prog_data.m:
> compiler/prog_io.m:
> compiler/mercury_to_goedel.m:
> compiler/mercury_to_mercury.m:
> 	Store field names as `sym_name's rather than strings.
> 	Use a `maybe' type rather than an empty string to designate
> 	an unlabelled field.
> 
> compiler/hlds_data.m:
> 	Define data structures to hold information about
> 	the field names visible in a module.
> 
> compiler/hlds_module.m:
> 	Add a field to type module_info to hold information
> 	about the fields visible in a module.
> 
> compiler/hlds_pred.m:
> 	Add predicates to identify field access function names,
> 	and to handle the arguments of field access functions.
> 
> compiler/make_hlds.m:
> compiler/hlds_goal.m:
> compiler/modecheck_call.m:
> compiler/higher_order.m:
> compiler/purity.m:
> compiler/polymorphism.m:
> compiler/dnf.m:
> compiler/cse_detection.m:
> compiler/lambda.m:
> 	Move `create_atomic_unification' from make_hlds.m to hlds_goal.m
> 	because it is used by several other modules.
> 
> compiler/hlds_goal.m:
> 	Add a version of goal_info_init which takes the context of
> 	the goal, for use by make_hlds.m.
> 
> compiler/type_util.m:
> 	Add a predicate `type_util__get_type_and_cons_defn' to
> 	get the hlds_type_defn and hlds_cons_defn for a user-defined
> 	constructor.
> 
> compiler/prog_util.m:
> 	Add predicates to add and remove prefixes or suffixes
> 	from the unqualified part of a sym_name.
> 
> compiler/prog_out.m:
> 	Add a predicate to convert a `sym_name/arity' to a string.
> 
> compiler/hlds_out.m:
> 	Add `hlds_out__simple_call_id_to_string' to convert a
> 	`pred_or_func - sym_name/arity' to a string for use in
> 	error messages.
> 
> compiler/purity.m:
> 	Thread through the pred_info so that the expansion of field accessor
> 	goals can add new variables.
> 
> compiler/mercury_to_mercury.m:
> library/ops.m:
> 	Reduce precedence of `^/2' for use as a field name separator.
> 
> 	Add operator `^'/1 to designate which side of the `:=' is
> 	the field name in a DCG field access goal.
> 
> 	Add operator `:=/2' for field update expressions. 
> 
> doc/reference_manual.texi:
> 	Document the new syntax.
> 
> doc/transition_guide.texi:
> 	Document the new operators.
> 
> tests/hard_coded/Mmakefile:
> tests/hard_coded/record_syntax.m:
> tests/hard_coded/record_syntax.exp:
> tests/invalid/Mmakefile:
> tests/invalid/record_syntax_errors.m:
> tests/invalid/record_syntax_errors.err_exp:
> 	Test cases.

That's good now, thanks.

I'm happy for you to commit now.


dgj
-- 
David Jeffery (dgj at cs.mu.oz.au) | If your thesis is utterly vacuous
PhD student,                    | Use first-order predicate calculus.
Dept. of Comp. Sci. & Soft. Eng.|     With sufficient formality
The University of Melbourne     |     The sheerist banality
Australia                       | Will be hailed by the critics: "Miraculous!"
                                |     -- Anon.
--------------------------------------------------------------------------
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