Re: A quirk in the syntax of Prolog
- From: ulrich@xxxxxxxxxxxxxxxxxxxxxxxxxx (Ulrich Neumerkel)
- Date: Wed, 02 Sep 2009 22:24:51 GMT
Feliks <feliks.kluzniak@xxxxxxxxxxxx> writes:
A Quirk in the syntax of Prolog....
Are we really being kind to the user by supporting such a surprising
and ambiguous convention?
Prolog programmers tend to avoid syntax issues and consider it a
windmill fight for the dragon book. Nevertheless, these issues hit us
unexpectedly from time to time. Here is one in the line of your
examples but with predefined operators only:
SICStus 3, YAP, B-Prolog:
f(dynamic-static) == f(-(dynamic,static)).
but
f((dynamic-static)) == f(dynamic(-(static))).
So within the argument list of f/1, a further pair of brackets for an
argument changes the argument's meaning.
SWI and ECLiPSe:
f(dynamic-static) == f(dynamic(-(static))).
but
f(static-dynamic) == f(-(static,dynamic)).
ISO 13211-1:1995 (ISO Part 1) cleaned up most of the ambiguous issues.
All cases above are rejected if dynamic is prefix, except for the one
with double brackets. GNU Prolog behaves that way ; XSB almost. Note
that ISO does have a dynamic/1 directive but no corresponding operator
declaration.
In my own opinion it is time to let go of it as quickly as possible.
What do you think?
What is missing in most systems is a way to enforce strict syntax.
IF/Prolog has it as required by 5.1 e. But this mode has to remove
all other implementation specific extensions at the same time. GNU
Prolog's syntax seems strict (not sure). But most implementations
still permit many implementation specific extensions for the sake of
backwards compatibility, but without the option for a strictly
conforming mode. Ideally, there would be a flag similar to the
frequently supported flag character_escapes.
Is there a significant and useful subset of the current syntax
extensions w.r.t. 13211-1's operators where many Prolog systems agree
with each other? Maybe there is one, but it will be difficult to
define precisely. In fact, ISO tried exactly this and it took quite
some time to reach the status quo. In 7.8.6 - 7.8.8 you can see the
remnants of that quest: E.g. ';'(E, O). can be written more
compactly as ;(E, O).
So what is the cost of enforcing strict syntax (optionally)? Some
predicate indicators would have to be written with extra brackets.
I.e. (is)/2 in place of is/2. Just noted such an issue in SWI's
library(clpfd) which tries to fit into the ISO system.
On the other hand, the nice properties of the ISO syntax are still not
very well known and exploited:
For one, there is the functor notation that can be read in regardless
of the operator table present. Also, the compact list notation can be
used with them.
And atoms as arguments of functors or lists never need brackets - no
matter what operator declarations are in effect. Maybe such
unnecessary brackets could be highlighted as a syntax warning?
.
- Follow-Ups:
- Re: A quirk in the syntax of Prolog
- From: Joachim Schimpf
- Re: A quirk in the syntax of Prolog
- References:
- A quirk in the syntax of Prolog
- From: Feliks
- A quirk in the syntax of Prolog
- Prev by Date: comp.lang.prolog Frequently Asked Questions
- Next by Date: Re: A quirk in the syntax of Prolog
- Previous by thread: A quirk in the syntax of Prolog
- Next by thread: Re: A quirk in the syntax of Prolog
- Index(es):
Relevant Pages
|
Loading