[m-dev.] Fw: Replacement syntax for DCGs

Michael Day mikeday at bigpond.net.au
Mon Nov 26 19:31:11 AEDT 2001


> How to you declare the predicate/function which uses this threading?
> 
> What about it you want it to have multiple modes?
> 
> What about it you want to using this syntax on higher order.  What are
> the implications of that?
> 
> I would be nice to generalise this to the case of having more than one
> pair of state arguments threaded.  How would you declare that?

I took Ralph's suggestion to be that predicates would be declared in the 
usual way, just as they are now for DCG clauses. The "io" and "array" are 
not specially named arguments, but rather names for the last and second 
last argument pairs of the predicate. Thus the declaration is unchanged, 
regardless of multiple modes, and you can have multiple state argument 
pairs. Presumably higher order predicates would look like this:

	(io ! pred(X::in, di, uo) is det :- foo(X, Y), io ! bar(Y))

which should be transformed into the usual DCG syntax:

	(pred(X::in, di, uo) is det --> { foo(X, Y) }, bar(Y))

One question... why have an atom "io" instead of a variable IO? That might
present a clearer picture of pseudo-imperative destructive update...

IO ! do_stuff :-
	IO ! write_string("Foo!").

Michael

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