for review: Try to clear up the arity confusion when declaring/defining DCG preds.

Peter Schachte pets at cs.mu.OZ.AU
Thu Mar 26 10:10:48 AEDT 1998


Fergus wrote:
> > I think it would be worth putting a note in the reference manual where
> > it talks about pred declarations that a predicate can be defined with
> > two fewer arguments than it is declared with if it is defined as a
> > DCG, and refer to the DCG section.
> 
> Do I hear you volunteering? ;-)

OWTH.

Try to clear up the arity confusion when declaring/defining DCG preds.

>From Fergus:
> On 26-Mar-1998, Peter Schachte <pets at students.cs.mu.oz.au> wrote:
> > Better still, I think there should be a specialized syntax for
> > declaring DCG predicates, ideally some variation on the EDCG
> > notation.  There should also be a special syntax for calling DCG
> > predicates from non-DCG code; maybe something like phrase/2,3 in Prolog.
> > Then the current practice of declaring and calling DCG predicates with
> > 2 extra arguments should be phased out.
> 
> Yes, I agree.


Estimated hours taken:  .2

reference_manual.texi:
	Try to clear up the confusion caused by defining a predicate
	with 2 fewer arguments than it was declared with.


Index: reference_manual.texi
===================================================================
RCS file: /home/staff/zs/imp/mercury/doc/reference_manual.texi,v
retrieving revision 1.90
diff -u -r1.90 reference_manual.texi
--- reference_manual.texi	1998/03/18 17:30:46	1.90
+++ reference_manual.texi	1998/03/25 23:01:37
@@ -969,6 +969,13 @@
 and only one function with a given name and arity in each module.
 It is an error to declare the same predicate or function twice.
 
+Note that a predicate defined using DCG notation (@pxref{DCG-rules})
+will appear to be defined with two fewer arguments than it is declared
+with.  It will also appear to be called with two fewer arguments when
+called from predicate defined using DCG notation.  However, when called
+from an ordinary predicate or function, it must have all the arguments
+it was declared with.
+
 The compiler infers the types of data-terms, and in particular the types
 of variables and overloaded constructors, functions, and predicates.
 A @dfn{type assignment} is an assignment of a type




More information about the developers mailing list