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

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Nov 26 15:09:35 AEDT 2001


On 26-Nov-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> 1. Any show stoppers in there?

I can see three problems right off.

First, the proposal does nothing about the common case that a value being
threaded through is read-only inside some calls and read-write inside others.
This could probably be fixed by using a second operator (maybe question mark)
instead of exclamation mark.

Second, it doesn't shorten calls, indeed, it makes lines containing calls
that access threaded values even longer.

Third, sometimes one does thread a value through most calls in the body of
a predicate (the code generator has such examples). In that case, your
notation would look horribly cluttered.

Has anyone tried to make a EDCG-like system by a mechanism such as
transforming:

p(..., cur X, next X) :-
	p1(cur X),
	p2(cur X, next X),
	p3(cur X, next X).

into

p(..., X0, X2) :-
	p1(X0),
	p2(X0, X1),
	p3(X1, X2).

and

q(...) :-
	q1(define X),
	q2(cur X, next X),
	q3(cur X, next X).

into

q(...) :-
	q1(X0),
	q2(X0, X1),
	q3(X1, X2).

You'd have to put restrictions on atomic goals (number of occurrence of
"cur X" or "define X" per goal <= 1, number of occurrence of "next X" per goal
<= number of occurrence of "cur X" in that goal). And it would be tempting
to try to apply "replacing equals with equals) to those occurrences of
"cur X" above.

I am not proposing this system, just asking if anyone has done it.

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