EDIT
I just remember that my existing open dict library use the term_expansion trick
to convert X.Y to eliminate “.”. To be honest, at the same time I remember that I felt that I was doing something very ad hoc.
As it is in library(pac/open-dict.pl)
.
% './2' and './3' are reserved for the dict in SWI-7.
% './2' is untuchable for the user in a direct way.
period_term(X):- functor(X, (.), 2), !.
period_term(role(_,_)).
%
period_args(X, A, B):- X=..[(.), A, B].
period_args(role(A, B), A, B).
end of EDit
Even reading your comment, still I have to time to understand behavior of “.”.
I think as Prolog reader has a privilege to process “.”, it is impossible
for the prolog user to control “.” by defining term_expansion or goal_expansion. However, your sample shows that I am wrong. I am confused.
This log might shows how I am confused. I appreciate if anyone points
what I am missing.
% swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.5.3-33-gd89fac4a2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- X = f(a.b).
EERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- asserta(user:goal_expansion(A.B, '.'(A, B))..
| .
ERROR: Syntax error: Operator expected
ERROR: asserta(user:goal_expansion(A.B, '.'(A, B)
ERROR: ** here **
ERROR: ).. .
?- asserta(user:term_expansion(A.B, '.'(A, B))).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [13] throw(error(instantiation_error,_8064))
ERROR: [10] '<meta-call>'(user:user: ...) <foreign>
?- X = a.b.
ERROR: Type error: `dict' expected, found `a' (an atom) % ' to get code highlight back in order
ERROR: In:
ERROR: [13] throw(error(type_error(dict,a),_1908))
ERROR: [10] '<meta-call>'(user:user: ...) <foreign>
?- current_op(X, Y, .).
X = 100,
Y = yfx.
?- write_canonical(a.b).
ERROR: Type error: `dict' expected, found `a' (an atom) % ' to get code highlight back in order
ERROR: In:
ERROR: [13] throw(error(type_error(dict,a),_9010))
ERROR: [10] '<meta-call>'(user:user: ...) <foreign>
ERROR: [9] toplevel_call(user:user: ...) at
?- write_canonical(X.b).
ERROR: Arguments are not sufficiently instantiated
ERROR: In:
ERROR: [13] throw(error(instantiation_error,_1858))
ERROR: [10] '<meta-call>'(user:user: ...) <foreign>
ERROR: [9] toplevel_call(user:user: ...) at /Users/cantor/lib/swipl/boot/toplevel.pl:1117
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- current_op(X, Y, .).
X = 100,
Y = yfx.