[m-dev.] New syntax proposal

Fergus Henderson fjh at cs.mu.oz.au
Mon Oct 6 17:33:16 AEST 1997


Thomas Charles CONWAY, you wrote:
> 
> The following diff proposes new syntax for higher-order pred expressions
> with DCG syntax. Comments on the new syntax very welcome.

> 	Pred = (pred(Arg1::Mode1, ..., ArgN::ModeN, DCGMode0, DCGMode1) is Det
> 			--> Goal)

That syntax is OK with me.

> Index: compiler/prog_io_dcg.m

> +:- pred parse_dcg_pred_goal(term, varset, goal, var, var, varset).
> +:- mode parse_dcg_pred_goal(in, in, out, out, out, out) is det.

You should document this predicate.

> Index: doc/reference_manual.texi
>  
> +For higher-order predicate expressions that thread an accumulator
> +pair, we have syntax that allows you to use DCG notation in the
> +goal of the expression:
> +
> + at example
> +Pred = (pred(Strings::in, Num::out, di, uo) is det -->
> +    io__write_string("The strings are: "),
> +    { list__length(Strings, Num) },
> +    io__write_strings(Strings),
> +    io__nl
> +)
> + at end example
> +
> + at noindent
> +which is equivalent to
> +
> + at example
> +Pred = (pred(Strings::in, Num::out, IO0::di, IO::uo) is det -->
> +    io__write_string("The strings are: ", IO0, IO1),
> +    list__length(Strings, Num),
> +    io__write_strings(Strings, IO1, IO2),
> +    io__nl(IO2, IO)
> +)
> + at end example

The reference manual should define the syntax and semantics of language constructs;
just giving an example is not sufficiently precise.

The syntax needs to be defined in the "Data-terms" section of the "Syntax" chapter.
The semantics should probably be given there too, using the "DCG-transform" function
defined in the "DCG-Rules" section.

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



More information about the developers mailing list