/*
I discovered the use of ``..``
in some old DEC-10 prolog code . %36'footnote;
It appears the the prolog vector ``[ _etc ]``
has it's origin's in the ``.`` .
Underlying the vector construct ``[ _etc_ ]``
in every standard prolog system
is an abstract syntax tree
based on the functor with name ``.``
Old prolog code uses the following (example)
construction for vectors :
<PRE>
/*
A=(a.b.nil) .
A=(a.b.c.d.nil) .
A=(a.b.c.d.(e.f.g.nil).nil) .
A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k).l.nil).nil) .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- A=(a.b.nil) .
A = [a,b|nil]
?- A=(a.b.c.d.nil) .
A = [a,b,c,d|nil]
?- A=(a.b.c.d.(e.f.g.nil).nil) .
A = [a,b,c,d,[e,f,g|nil]|nil]
?- A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k).l.nil).nil) .
A = [a,b,c,d,[E,{f},g,[h,i],[j|k],l|nil]|nil]
?- (halt) .
% YAP execution halted
</PRE>
Note the use of ``nil`` to mark the end of the vector .
Because of that usage , the atom ``nil`` was
(by convention) representativ of the empty vector .
It seems that ``[]`` emerged as a later development within
prolog as the way to specify ``nil`` .
Perhaps it was in correspondence to the appearance
of ``[`` as ``]`` as available characters ?
Early computers had a much more limited character set and
the development of the character set we know as ascii today
was over a period of years .
<PRE>
/*
A=(a.b.c.d.[]) .
A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k).l.nil).nil) .
A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k).l.[]).[]) .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- A=(a.b.c.d.[]) .
A = [a,b,c,d]
?- A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k).l.nil).nil) .
A = [a,b,c,d,[E,{f},g,[h,i],[j|k],l|nil]|nil]
?- A=(a.b.c.d.(E.{f}.(g).[h,i].(j.k.[]).l.[]).[]) .
A = [a,b,c,d,[E,{f},g,[h,i],[j,k],l]]
?- (halt) .
% YAP execution halted
</PRE>
Because of that usage , the atom ``[]`` became representativ
of the empty vector .
Working backwards from the usage of today ,
a typical prolog construct is ...
<PRE>
/*
A=[a,b|[c,d]] .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- A=[a,b|[c,d]] .
A = [a,b,c,d]
?- (halt) .
% YAP execution halted
</PRE>
this usage of ``|`` also has it's origins in the ``.`` ...
<PRE>
/*
[a,b|[c,d]] = [a,b,..[c,d]] .
A =[a,b,..[c,d]] .
A =[a,..[b,c]] .
A =..[a,..[b,c]] .
A =..[a,commentary per O'Keefe..[b,c]] .
A =..[a,commentary_per_O_Keefe..[b,c]] .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- [a,b|[c,d]] = [a,b,..[c,d]] .
yes
?- A =[a,b,..[c,d]] .
A = [a,b,c,d]
?- A =[a,..[b,c]] .
A = [a,b,c]
<MARK>
?- A =..[a,..[b,c]] .
A = a(b,c)
</MARK>
/* ^^^^^^^^ super-kewl , eh ? */
?- A =..[a,commentary per O'Keefe..[b,c]] .
| wtf;lkawuerpo730ru
| ;kasjdflka
| '
| )
| (
| ..
| .
SYNTAX ERROR at user, near line 5:
A =.. [ a , commentary
<==== HERE ====>
per O Keefe..[b,c]] .
wtf;lkawuerpo730ru
;kasjdflka
)( ...
?- A =..[a,commentary_per_O_Keefe..[b,c]] .
SYNTAX ERROR at user, near line 4:
A =.. [ a , commentary_per_O_Keefe
<==== HERE ====>
.. [ b , c ] ].
?- (halt) .
% YAP execution halted
</PRE>
These seem to be early and traditonal uses
of the ``.`` and the ``..`` within prolog .
I suspect their origins in c-prolog or perhaps DEC-10 ,
(either of which BTW I would love o have a copy of if you are willing to share) .
Within Mercury and swipl , however ,
neither the ``.`` nor the ``..`` are functional as described .
I reported a bug to swipl about ``.` ;
assuming non-conformance to traditional
and standard prolog systems was of interest ;
it appears that it is not .
https://github.com/SWI-Prolog/issues/issues/55
The author of swipl makes the suggestion of using
``term_expansion`` , however neither the use of
``term_expansion`` nor ``goal_expansion``) can fix the
following basic compatibility issues ...
<PRE>
/*
(a.b.[]) =[a,b] .
A ={ foo:a.b.nil } .
[a,b|[c,d]] = [a,b,..[c,d]] .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- (a.b.[]) =[a,b] .
yes
?- A ={ foo:a.b.nil } .
A = {[foo:a,b|nil]}
?- [a,b|[c,d]] = [a,b,..[c,d]] .
yes
?- (halt) .
% YAP execution halted
$ swipl
+ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.27)
Copyright (c) 1990-2016 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is LGPL free software,
and you are welcome to redistribute it under certain conditions.
For help, use ?- help(Topic). or ?- apropos(Word).
?- (a.b.[]) =[a,b] .
ERROR: Type error: `dict' expected, found `a' (an atom)
?- A ={ foo:a.b.nil } .
ERROR: Type error: `dict' expected, found `a' (an atom)
?- [a,b|[c,d]] = [a,b,..[c,d]] .
ERROR: Syntax error: Operator expected
ERROR: [a,b|[c,d]] = [a,b,.
ERROR: ** here **
ERROR: .[c,d]] .
?- (end_of_file) .
% halt
</PRE>
... suggesting to me that perhaps the author of swipl does
not know prolog very well (term_expansion?!??!) or is not
interested in prolog conformance or is interested in
establishing vendor lock-in .
Beyond the incompatibility with ``.`` and ``..`` ,
the ``{ _etc }`` as syntax in prolog is supposed to be
identical to the ``( _etc )`` in all ways , with the
exception that ``foo{_etc}`` is equivalent to ``foo({_etc})`` .
That comes in VERY handy when you are using a prolog system
that parses whitespace as an operator ,
enabling prolog to easily handle other-language constructs such as ...
``void int foo(int x) { int y ; y = x + 1 ; return y ; }``
... the syntax of which which might be vaguely familiar to some readers .
<PRE>
/*
(op(2'1,'fy','foo')) .
A =( foo {a} ) , (write_canonical(A)) .
A =( foo ({a}) ) , (write_canonical(A)) .
A =( foo({a}) ) , (write_canonical(A)) .
A =( foo{a} ) , (write_canonical(A)) .
*/
$ yap
+ yap
YAP 6.2.2 (x86_64-linux): Wed Sep 7 07:48:47 PDT 2016
MYDDAS version MYDDAS-0.9.1
?- (op(2'1,'fy','foo')) .
yes
?- A =( foo {a} ) , (write_canonical(A)) .
foo({}(a))A = foo{a}
?- A =( foo ({a}) ) , (write_canonical(A)) .
foo({}(a))A = foo{a}
?- A =( foo({a}) ) , (write_canonical(A)) .
foo({}(a))A = foo{a}
?- A =( foo{a} ) , (write_canonical(A)) .
foo({}(a))A = foo{a}
?- (halt) .
% YAP execution halted
$ swipl
+ swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.3.27)
Copyright (c) 1990-2016 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is LGPL free software,
and you are welcome to redistribute it under certain conditions.
For help, use ?- help(Topic). or ?- apropos(Word).
?- (op(2'1,'fy','foo')) .
true.
?- A =( foo {a} ) , (write_canonical(A)) .
foo({a})
A = foo {a}.
?- A =( foo ({a}) ) , (write_canonical(A)) .
foo({a})
A = foo {a}.
?- A =( foo({a}) ) , (write_canonical(A)) .
foo({a})
A = foo {a}.
?- A =( foo{a} ) , (write_canonical(A)) .
ERROR: Syntax error: colon_expected
ERROR: A =( foo{
ERROR: ** here **
ERROR: a} ) , (write_canonical(A)) .
?- (end_of_file) .
% halt
</PRE>
See also
http://www.complang.tuwien.ac.at/ulrich/iso-prolog/SWI7_and_ISO .
%36'footnote; liar .
~~ kintalken ~~
*/