The following happens:
?- A = (\).
A = (\).
?- A = '\\' .
caught: error(syntax_error(incomplete_reduction),read_term/3:1)
?-
Expected the second query to succeed.
We have:
?- current_op(Pri, Fix, \). Pri = 200, Fix = fy ; false.
So, \ is a predefined prefix operator.
6.3.1.3 Atoms
...
term = atom ;
Abstract: a a
Priority: 1201
Condition:a is an operator
An atom which is an operator shall not be the immediate
operand (3.120) of an operator. The priority of a term
consisting of an operator is therefore given the priority
1201 rather than the normal 0.
We also have for example:
?- X = + . caught: error(syntax_error(incomplete_reduction),read_term/3:1)
For the same reason as above.
Write (+) and (\\) etc., i.e. enclose the term in round brackets, to give it priority 0:
term = open ct, term, close ;
Abstract: a a
Priority: 0 1201
For example:
?- X = (+). X = (+).
Thank you, so this also fails ?- X = is., closing.
Yes exactly!
This is why I always write (#>)/2, (#=)/2 etc. to refer to these predicates: To make them valid Prolog terms when #> and #= are operators!
Scryer Prolog's syntactic strictness and ISO conformance is an amazing feature: It means that we can use the system to test what is portable syntax, and what is not. It's a huge attraction of the system.
Most helpful comment
Yes exactly!
This is why I always write
(#>)/2,(#=)/2etc. to refer to these predicates: To make them valid Prolog terms when#>and#=are operators!Scryer Prolog's syntactic strictness and ISO conformance is an amazing feature: It means that we can use the system to test what is portable syntax, and what is not. It's a huge attraction of the system.