bimbart@kulcs.cs.kuleuven.ac.be (Bart Demoen) (01/15/91)
I am sending the folowing on behalf of Roger Scowen:
I am convener of the ISO Working Group standardizing Prolog and have
been reading the correspondence on if-then-else in Prolog.
Defining an international standard for Prolog is taking a long time
because there are always at least two views proposed for the
standard on every issue:
(1) keep it like it is,
(2) let's do it properly now.
Currently the predominant view seems to be the former, and when there
is no agreement, there is a tendency to leave that feature out.
Some of the apparent oddities of
Cond -> Then ; Else
in Prolog arise because it is parsed as
';'( '->'(Cond, Then), Else ).
It is then natural for
fail -> Then
to fail rather than succeed so that the "Else" will be executed in
fail -> Then ; Else
It is also natural to treat "->" as a local cut so that on resatisfying
true -> Then ; Else
we will not execute both "Then" and "Else".
Most (but not all) Edinburgh implementations include this feature, and
nearly all of them agree on its semantics. It is widely used, and simple
to understand in practical cases when the programmer follows Richard
O'Keefe's recommendation to write conditionals with the style:
( <condition_1> ->
<if_branch_1>
; <condition_2> ->
<if_branch_2>
...
; <else_branch>
)
exactly like an Ada if statement, with "(" acting like "if",
"->" acting like "then", ";" acting like "else if" or
"else", and ")" acting like "end if".
The ISO working group currently intends to provide if-then-else in the
standard with the semantics above, that is, agreeing with most
Edinburgh Prolog implementations. The current proposal also provides
a definite meaning to all the tricky cases mentioned in comp.lang.prolog.
But readers are warned that a standards committee may (and often does)
change its mind.
Roger Scowen, SC22 WG17 (Prolog) Convener,
DITC/93, National Physical Laboratory, Teddington, Middlesex, England TW11 0LW
15 January 1991
Tel (Britain): 081 943 6956 Tel (Abroad): +44 81 943 6956
Fax (Britain): 081 977 7091 Fax (Abroad): +44 81 977 7091
Email: rss@seg.npl.co.uk Telex: 262344