Operator priority: >>/2 vs. =/2

Help requests on developing Logtalk applications

Moderator: Paulo Moura

Post Reply
Hibeus
Posts: 7
Joined: Wed Jan 26, 2011 2:09 am

Operator priority: >>/2 vs. =/2

Post by Hibeus » Fri Jan 28, 2011 1:41 am

Hello,

I am writing some anonymous predicates and ran into the following case:

Code: Select all

?- logtalk << call([X, Y, Z]>>Z = X, 1, 1, T).
ERROR: Undefined procedure: (=)/5
ERROR:   However, there are definitions for:
ERROR:         (=)/2
ERROR:         (=)/2
?- callable(Z = X).
true.

?- logtalk << call([X, Y, Z]>>(Z = X), 1, 1, T).
T = 1.
The Logtalk reference manual (2.42.2) says the right-hand side of >>/2 should be a callable/1 term, so I expected the first case above to behave just like the last one. Is this difference in behaviour intended? For the record, I am using SWI Prolog 5.11.13-3-g4e0fdd0.

Thanks in advance for your answer

Paulo Moura
Logtalk developer
Posts: 475
Joined: Sat May 05, 2007 8:35 am
Location: Portugal
Contact:

Re: Operator priority: >>/2 vs. =/2

Post by Paulo Moura » Fri Jan 28, 2011 2:28 am

Logtalk reuses standard Prolog operators in its lambda expressions implementation. This design choice avoids adding any new operators, which can be problematic in terms of portability (the current version runs out-of-the-box on nine Prolog compilers). Logtalk doesn't change the priority or type of these operators. The downside is that, as you have found, parenthesis may be necessary in order to obtain a syntactically correct lambda expression.

P.S. For an overview of Logtalk lambda expressions, see:
http://blog.logtalk.org/2009/12/08/lamb ... n-logtalk/
Paulo Moura
Logtalk developer

Hibeus
Posts: 7
Joined: Wed Jan 26, 2011 2:09 am

Re: Operator priority: >>/2 vs. =/2

Post by Hibeus » Fri Jan 28, 2011 3:45 am

Ah, I understand now why you made this choice, and agree that trading a pair of parentheses for such portability is good. And thank you for the examples, also !

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest