On 4/02/18 01:10, Julio Di Egidio wrote:
[...]
> in 2018 Prolog is what it is, a programming language with an operational
> semantics, period.
I strongly disagree. Prolog has *both* a procedural (your
"operational") and a declarative semantics, both of which are useful.
The declarative semantics is very useful for (among other things)
explaining recursions to beginners who have a procedural mindset from
earlier exposure to Basic etc.
A simple example is the recursive append predicate:
%% append(?List1, ?List2, ?List1AndList2)
%
% List1AndList2 is the concatenation of List1 and List2
%
append([], Ys, Ys).
append([X|Xs], Ys, [X|Zs]) :-
append(Xs, Ys, Zs).
Here's a declarative reading of the code:
Clause 1: Appending an empty list in front of a list equals that list.
Clause 2: Appending [X|Xs] in front of a list equals the result of
appending Xs in front of the list, and then putting X in front of that
result.
This neatly avoids any recursion boggle for beginners. Indeed, it
doesn't even look like programming as they have known it.
After understanding this declarative reading they can then run traces of
append's execution on various examples and more readily understand what
is going procedurally.
> Indeed at least one thing I'd say: that if a book does not
> make at least clear the distinction and exact meaning of the denotational (was
> that the name?)
No. "Denotational semantics" in logic involves mapping syntactic
structures into semantic sets; in programming languages it usually
involves Scott's Domain Theory (which is a denotational semantics in the
logical sense).
> vs the operational semantics of Prolog, then it's worse than
> useless...
Making the distinction between Prolog's declarative and procedural
semantics (semanticses? semantices?) is indeed useful, as in my above
example. But IMO it's not the /sine quo non/ of learning Prolog.
[...]