[m-dev.] Fw: Replacement syntax for DCGs
Mark Brown
dougl at cs.mu.OZ.AU
Tue Nov 27 17:38:36 AEDT 2001
On 26-Nov-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Here's yet another DCG-replacement suggestion. I think it's simpler
> and more elegant than EDCGs (see http://www.cs.mu.oz.au/research/mercury/mailing-lists/mercury-developers/mercury-developers.9912/0114.html ), but
> EDCGs have the advantage of having been implemented, but not
> integrated into the compiler.
>
> Anyway, comments welcome.
>
>
>
> Problem 1: DCG syntax is ugly and puts the cart before the horse (it's
> very common to see the majority of a DCG clause { escaped } with only a
> few unescaped goals.)
>
> Problem 2: DCGs are weak because they only support a single threaded
> pair.
Personally, the most frequently occurring problem that I have with DCGs
is forgetting that the rule I am looking at is a DCG-rule at all. This
is not a major problem -- the usual effect is that I'll misquote the
arity of a predicate, or get an error for =/4 being undefined -- but I
think that the cause of this problem is that the syntactic cue which tells
me that a goal is a DCG-goal, namely whether the principal functor of
the rule is ':-' or '-->', can be quite a long way away from the goal
itself. If there are no DCG escapes in any nearby code, then I find
that it is very easy to forget that there is a pair of implicit arguments
to an atom.
With this proposal, the problem would be mitigated because any affected
atom would be adjacent to the '!' operator. This provides a visual cue
at the location that is affected, as opposed to a DCG escape which
provides a visual cue only at locations which are _not_ affected.
For this reason, my initial view is that this proposal is worth
considering. But I'd like to see a fuller exposition of the proposed
transformation -- it is too hard to be confident there are no
show-stoppers before then.
Cheers,
Mark.
--------------------------------------------------------------------------
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