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

Simon Taylor stayl at cs.mu.OZ.AU
Tue Jan 25 12:41:43 AEDT 2000



Estimated hours taken: 1

Address some issues Fergus raised in his review of the record syntax
documentation.

compiler/make_hlds.m:
tests/hard_coded/record_syntax.m:
	Change the syntax for DCG field extraction from
	`Value := ^ field' to `Value =^ field'.

NEWS:
doc/reference_manual.texi:
	Document the changed syntax.

doc/reference_manual.texi:
	Clear up the description of how to construct higher-order
	terms for field access functions.

library/ops.m:
compiler/mercury_to_mercury.m:
doc/transition_guide.texi:
	Add `=^' and `:=' to the operator table.	

Index: NEWS
===================================================================
RCS file: /home/mercury1/repository/mercury/NEWS,v
retrieving revision 1.159
diff -u -u -r1.159 NEWS
--- NEWS	2000/01/16 04:34:37	1.159
+++ NEWS	2000/01/24 05:15:12
@@ -7,6 +7,11 @@
   without writing lots of trivial access predicates.
   See the "Field access functions" section of the "Types" chapter
   of the Mercury Language Reference Manual for details.
+
+  Note that the syntax has changed slightly since the version
+  that appeared in the release of the day in early January 2000.
+  `Value =^ field' is now the syntax for DCG field selection,
+  rather than `Value := ^ field'.
  
 * Functions `int:^/2' and `integer:^/2' have been removed.
   Use `int__xor/2' and `integer__xor/2' instead.
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.321
diff -u -u -r1.321 make_hlds.m
--- make_hlds.m	2000/01/13 06:16:06	1.321
+++ make_hlds.m	2000/01/24 04:56:48
@@ -5007,12 +5007,15 @@
 				VarSet0, Subst, Goal, VarSet, Info0, Info)
 	;
 		% check for a DCG field access goal:
-		% get:  Field := ^ field
+		% get:  Field =^ field
 		% set:  ^ field := Field
-		{ Name = unqualified(":=") }
+		{ Name = unqualified(Operator) },
+		( { Operator = "=^" }
+		; { Operator = ":=" }
+		)
 	->
 		{ term__apply_substitution_to_list(Args0, Subst, Args1) },
-		transform_dcg_record_syntax(Args1, Context,
+		transform_dcg_record_syntax(Operator, Args1, Context,
 			VarSet0, Goal, VarSet, Info0, Info)
 	;
 		% check for an Aditi builtin
@@ -5095,38 +5098,32 @@
 	unravel_unification(A, B, Context, explicit, [],
 			VarSet0, Goal, VarSet, Info0, Info).
 
-:- inst aditi_update_str =
-	bound(	"aditi_insert"
-	;	"aditi_delete"
-	;	"aditi_bulk_insert"
-	;	"aditi_bulk_delete"
-	;	"aditi_modify"
-	).
+:- inst dcg_record_syntax_op = bound("=^"; ":=").
 
-:- pred transform_dcg_record_syntax(list(prog_term), prog_context,
+:- pred transform_dcg_record_syntax(string, list(prog_term), prog_context,
 		prog_varset, hlds_goal, prog_varset, qual_info, qual_info,
 		io__state, io__state).
-:- mode transform_dcg_record_syntax(in, in, in, out, out,
-		in, out, di, uo) is det.
+:- mode transform_dcg_record_syntax(in(dcg_record_syntax_op),
+		in, in, in, out, out, in, out, di, uo) is det.
 
-transform_dcg_record_syntax(ArgTerms0, Context, VarSet0,
+transform_dcg_record_syntax(Operator, ArgTerms0, Context, VarSet0,
 		Goal, VarSet, Info0, Info) -->
 	{ goal_info_init(Context, GoalInfo) },
 	(
 		{ ArgTerms0 = [LHSTerm, RHSTerm,
 				TermInputTerm, TermOutputTerm] },
 		{
+			Operator = "=^",
+			AccessType = get,
+			FieldNameTerm = RHSTerm,
+			FieldValueTerm = LHSTerm
+		;
+			Operator = ":=",
+			AccessType = set,
 			LHSTerm = term__functor(term__atom("^"),
-				[FieldNameTerm0], _)
-		->
+				[FieldNameTerm0], _),
 			FieldNameTerm = FieldNameTerm0,
-			FieldValueTerm = RHSTerm,
-			AccessType = set
-		;
-			RHSTerm = term__functor(term__atom("^"),
-				[FieldNameTerm], _),
-			FieldValueTerm = LHSTerm,
-			AccessType = get
+			FieldValueTerm = RHSTerm
 		}
 	->
 		{ parse_field_name_list(FieldNameTerm, MaybeFieldNames) },
@@ -5168,7 +5165,7 @@
 		io__set_exit_status(1),
 		prog_out__write_context(Context),
 		io__write_string(
-		"Error: expected `Field := ^ field1 ^ ... ^ fieldN'\n"),
+		"Error: expected `Field =^ field1 ^ ... ^ fieldN'\n"),
 		prog_out__write_context(Context),
 		io__write_string("  or `^ field1 ^ ... ^ fieldN := Field'.\n"),
 		prog_out__write_context(Context),
@@ -5499,6 +5496,14 @@
 	).
 
 %-----------------------------------------------------------------------------%
+
+:- inst aditi_update_str =
+	bound(	"aditi_insert"
+	;	"aditi_delete"
+	;	"aditi_bulk_insert"
+	;	"aditi_bulk_delete"
+	;	"aditi_modify"
+	).
 
 	% See the "Aditi update syntax" section of the
 	% Mercury Language Reference Manual.
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.165
diff -u -u -r1.165 mercury_to_mercury.m
--- mercury_to_mercury.m	2000/01/13 06:16:21	1.165
+++ mercury_to_mercury.m	2000/01/24 05:17:25
@@ -2774,6 +2774,7 @@
 mercury_infix_op("-->").
 mercury_infix_op(":-").
 mercury_infix_op("::").
+mercury_infix_op(":=").
 mercury_infix_op("where").
 mercury_infix_op("sorted").	/* NU-Prolog */
 mercury_infix_op("else").
@@ -2797,6 +2798,7 @@
 mercury_infix_op("\\=").	/* Prolog */
 mercury_infix_op("\\==").	/* Prolog */
 mercury_infix_op("=\\=").	/* Prolog */
+mercury_infix_op("=^").
 mercury_infix_op(">").
 mercury_infix_op(">=").
 mercury_infix_op("<").
Index: doc/reference_manual.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/reference_manual.texi,v
retrieving revision 1.167
diff -u -u -r1.167 reference_manual.texi
--- reference_manual.texi	2000/01/13 06:18:30	1.167
+++ reference_manual.texi	2000/01/25 00:51:25
@@ -723,7 +723,7 @@
 transform(V_in, V_out, :=(Term)) = (V_out = Term)
 @end example
 
- at item @var{Term} := ^ @var{field1} ^ ... ^ @var{fieldN}
+ at item @var{Term} =^ @var{field1} ^ @dots{} ^ @var{fieldN}
 A DCG field selection.
 Unifies @var{Term} with the result of applying the functions
 @var{field1} @dots{} @var{fieldN} to the implicit DCG argument.
@@ -734,7 +734,7 @@
 
 Semantics:
 @example
-transform(V_in, V_out, Term := ^ field1 ^ @dots{} ^ fieldN) =
+transform(V_in, V_out, Term =^ field1 ^ @dots{} ^ fieldN) =
         (Term = V_in ^ field1 ^ @dots{} ^ fieldN, V_out = V_in)
 @end example
 
@@ -1341,10 +1341,12 @@
 the corresponding field selection function is also exported from the module.
 
 By default, this function has no declared modes --- the modes are inferred at
-each call to the function.
+each call to the function. However, the modes of this function may be
+explicitly declared, in which case it will have only the declared modes.
 
-An explicit lambda expression must be used to create a higher-order term
-from a field selection function, unless a mode declaration is supplied.
+To create a higher-order term from a field selection function an
+explicit lambda expression must be used, unless a single mode
+declaration is supplied for the field selection function.
 
 @node Field update
 @subsection Field update
@@ -1365,11 +1367,13 @@
 If the declaration of the field is in the interface section of the module,
 the corresponding field update function is also exported from the module.
 
-By default, this function has no declared modes --- the modes
-are inferred at each call to the function.
+By default, this function has no declared modes --- the modes are inferred at
+each call to the function. However, the modes of this function may be
+explicitly declared, in which case it will have only the declared modes.
 
-An explicit lambda expression must be used to create a higher-order term
-from a field update function, unless a mode declaration is supplied.
+To create a higher-order term from a field update function an
+explicit lambda expression must be used, unless a single mode
+declaration is supplied for the field update function.
 
 Some fields cannot be updated using field update functions.
 For the constructor @samp{unsettable/2} below, neither field may be updated
Index: doc/transition_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/transition_guide.texi,v
retrieving revision 1.32
diff -u -u -r1.32 transition_guide.texi
--- transition_guide.texi	2000/01/13 06:18:34	1.32
+++ transition_guide.texi	2000/01/24 04:15:32
@@ -137,6 +137,7 @@
 ==              xfx             700
 ==>             xfx             1175
 =>              xfy             920
+=^              xfx             650
 >               xfx             700
 >=              xfx             700
 >>              yfx             400
Index: library/ops.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/ops.m,v
retrieving revision 1.28
diff -u -u -r1.28 ops.m
--- ops.m	2000/01/13 06:19:05	1.28
+++ ops.m	2000/01/24 04:11:32
@@ -155,6 +155,7 @@
 ops__op_table("==>", after, xfx, 1175).		% Mercury extension
 ops__op_table("=>", after, xfy, 920).		% Mercury/NU-Prolog extension
 ops__op_table("=\\=", after, xfx, 700).		% standard ISO Prolog (*)
+ops__op_table("=^", after, xfx, 650).		% Mercury extension
 ops__op_table(">", after, xfx, 700).		% standard ISO Prolog
 ops__op_table(">=", after, xfx, 700).		% standard ISO Prolog
 ops__op_table(">>", after, yfx, 400).		% standard ISO Prolog
Index: tests/hard_coded/record_syntax.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/record_syntax.m,v
retrieving revision 1.1
diff -u -u -r1.1 record_syntax.m
--- record_syntax.m	2000/01/13 06:19:28	1.1
+++ record_syntax.m	2000/01/24 05:14:58
@@ -117,9 +117,9 @@
 :- pred dcg_syntax(io__state::di, io__state::uo, foo::in, foo::out) is det.
 
 dcg_syntax(IO0, IO) -->
-	Arg1 := ^ arg1,
+	Arg1 =^ arg1,
 	{ write_arg("DCG ^ arg1", Arg1, IO0, IO1) },
-	Arg4 := ^ arg3 ^ arg4,
+	Arg4 =^ arg3 ^ arg4,
 	{ write_arg("DCG ^ arg3 ^ arg4", Arg4, IO1, IO2) },
 
 	^ arg1 := 8,
Index: tests/invalid/record_syntax_errors.err_exp
===================================================================
RCS file: /home/mercury1/repository/tests/invalid/record_syntax_errors.err_exp,v
retrieving revision 1.1
diff -u -u -r1.1 record_syntax_errors.err_exp
--- record_syntax_errors.err_exp	2000/01/13 06:19:42	1.1
+++ record_syntax_errors.err_exp	2000/01/24 23:53:56
@@ -1,6 +1,6 @@
 record_syntax_errors.m:028: In DCG field update goal:
 record_syntax_errors.m:028:   error: expected field name at term `Field'.
-record_syntax_errors.m:031: Error: expected `Field := ^ field1 ^ ... ^ fieldN'
+record_syntax_errors.m:031: Error: expected `Field =^ field1 ^ ... ^ fieldN'
 record_syntax_errors.m:031:   or `^ field1 ^ ... ^ fieldN := Field'.
 record_syntax_errors.m:031:   in DCG field access goal.
 record_syntax_errors.m:048: Error: clause for predicate `record_syntax_errors:term_type_error/1'
--------------------------------------------------------------------------
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