[m-rev.] for review: change list constructor from `./2' to `[|]/2'
Simon Taylor
stayl at cs.mu.OZ.AU
Mon Sep 24 18:05:05 AEST 2001
On 24-Sep-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 23-Sep-2001, Simon Taylor <stayl at cs.mu.OZ.AU> wrote:
> > Change the list constructor from `./2' to `[|]/2'. `./2' will
> > eventually become the module qualification operator.
>
> Are there any bootstrapping issues with this change?
Once this change is installed, people will need to rebuild interface
files that refer to `./2' e.g. library/list.int. This will break
installation of the source distribution in some cases (when C files
need to be updated) so I'll need to update the check in configure.in
once this change has been installed everywhere.
> > +++ NEWS 2001/09/23 03:44:04
> > @@ -22,6 +22,11 @@
> > Reference Manual.
> >
> > Changes to the Mercury standard library:
> > +* The constructor for lists is now called '[|]' rather than '.'.
> > + `./2' will eventually become the module qualification operator.
> > + This change only affects programs which use `./2' explicitly.
> > + Programs which only use the `[H | T]' syntax will be unaffected.
>
> This is a change to the language rather than to the standard library.
It's actually a change to both. For example, the behaviour of
parser__read_term has changed.
> > Index: doc/reference_manual.texi
> > ===================================================================
> > -However, the meaning of some terms in Mercury is different to that
> > -in Prolog. @xref{Data-terms}.
> > +Also, the constructor for list terms in Mercury is @code{[|]/2}, not
> > + at code{./2} as in Prolog. The meaning of some terms in Mercury is
> > +different to that in Prolog. @xref{Data-terms}.
>
> I think it would be better to split the last sentence into a new
> paragraph:
>
> Note, however, that the meaning of some terms ...
Done.
> > +The following terms are all equivalent:
> > + at example
> > +[1, 2, 3]
> > +[1, 2 | [3]]
> > +[1 | [2, 3]]
> > +'[|]'(1, '[|]'(2, '[|]'(3, [])))
> > + at end example
>
> I suggest also including
>
> [1, 2, 3 | []]
>
> in that list of examples.
Done.
> > Index: tests/debugger/declarative/app.exp
> > ===================================================================
> > RCS file: /home/mercury1/repository/tests/debugger/declarative/app.exp,v
> > retrieving revision 1.10
> > diff -u -u -r1.10 app.exp
> > --- tests/debugger/declarative/app.exp 2000/10/01 03:13:42 1.10
> > +++ tests/debugger/declarative/app.exp 2001/09/23 07:34:37
> > @@ -15,7 +15,10 @@
> > mdb> finish -n
> > 16: 5 5 EXIT pred app:app/3-0 (det) app.m:26 (app.m:28)
> > mdb> dd
> > -app([4, 5], [6, 7, 8], [4, 5, 6, 7, 8])
> > +pred app
> > + [4, 5]
> > + [6, 7, 8]
> > + [4, 5, 6, 7, 8]
>
> That change appears to be unrelated.
It's not. `browser/declarative_user__check_decl_atom_size' uses
a fairly crude heuristic to determine whether an atom will fit
on a line. Now that the list constructor is three characters long
rather than one, there are a few places in the tests which,
according to the heuristic, will no longer fit on one line.
I'm not sure whether it's worth special casing `[|]' in the
heuristic. I'll leave it as it is for now. Mark can decide
what he wants to do with it.
Simon.
--- NEWS 2001/09/24 05:47:50 1.4
+++ NEWS 2001/09/24 08:04:01
@@ -2,6 +2,11 @@
----------------------------------
Changes to the Mercury language:
+* The constructor for lists is now called '[|]' rather than '.'.
+ `./2' will eventually become the module qualification operator.
+ This change only affects programs which use `./2' explicitly.
+ Programs which only use the `[H | T]' syntax will be unaffected.
+
* We've extended the language to allow you to specify different clauses
for different modes of a predicate or function. This is done by
putting mode annotations in the head of each clause.
@@ -22,10 +27,15 @@
Reference Manual.
Changes to the Mercury standard library:
-* The constructor for lists is now called '[|]' rather than '.'.
- `./2' will eventually become the module qualification operator.
- This change only affects programs which use `./2' explicitly.
- Programs which only use the `[H | T]' syntax will be unaffected.
+* As mentioned above, the constructor for lists has changed from './2'
+ to `[|]/2'. This change affects the behaviour of the term manipulation
+ predicates in the standard library when dealing with values of
+ type `term__term/1' representing lists. The affected predicates are
+ parser__read_term, parser__read_term_from_string, term__type_to_term,
+ term__term_to_type, term_io__read_term and term_io__write_term.
+ Also beware that std_util__functor and std_util__deconstruct now
+ return `[|]' rather than `.' for lists, and calls to std_util__construct
+ which construct lists may need to be updated.
* The predicates and functions in int.m, float, math.m and array.m now
generate exceptions rather than program aborts on domain errors and
--- reference_manual.texi 2001/09/24 05:49:23 1.2
+++ reference_manual.texi 2001/09/24 05:57:15
@@ -317,7 +317,9 @@
as described below,
and we support an extended set of builtin operators. @xref{Builtin Operators}.
Also, the constructor for list terms in Mercury is @code{[|]/2}, not
- at code{./2} as in Prolog. The meaning of some terms in Mercury is
+ at code{./2} as in Prolog.
+
+Note, however, that the meaning of some terms in Mercury is
different to that in Prolog. @xref{Data-terms}.
A term is either a variable or a functor.
@@ -350,6 +352,7 @@
The following terms are all equivalent:
@example
[1, 2, 3]
+[1, 2, 3 | []]
[1, 2 | [3]]
[1 | [2, 3]]
'[|]'(1, '[|]'(2, '[|]'(3, [])))
Index: std_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/std_util.m,v
retrieving revision 1.240
diff -u -u -r1.240 std_util.m
--- std_util.m 2001/08/24 09:31:25 1.240
+++ std_util.m 2001/09/24 07:47:20
@@ -518,7 +518,7 @@
%
% - for user defined types, the functor that is given
% in the type definition. For lists, this
- % means the functors ./2 and []/0 are used, even if
+ % means the functors [|]/2 and []/0 are used, even if
% the list uses the [....] shorthand.
% - for integers, the string is a base 10 number,
% positive integers have no sign.
--------------------------------------------------------------------------
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