trealla
trealla copied to clipboard
Postfix difficulties
?- current_op(Pri,Fix,.>).
false.
?- op(9,yf,.>).
true.
?- write_canonical(a.> .>).
outputs(".>(a)"), unexpected. % added
outputs(".>(.>(a))").
?- write_canonical(((a).>) .>).
outputs(".>(a)"), unexpected.
?- writeq(((a) .>) .>).
outputs("a.>"), unexpected.
outputs("a.> .>"). % expected, but not found
?- T = (((a) .>) .>).
T = a.>.
^ space missing
Just to clarify for the first test above I get:
$ tpl
?- op(9,yf,.>).
true.
?- write_canonical(a.> .>).
.>(a) true.
?-
So all are actually wrong.
More weirdness...
?- writeq(f(a) .>), nl.
a.>
true.
?-
I thought at first it was printing, but definitely a parsing issue.
$ scryer-prolog
?- op(9,yf,abc).
true.
?- T = (1+2) abc, write_canonical(T), nl.
abc(+(1,2))
T = (1+2)abc.
?-
$ tpl
?- op(9,yf,abc).
true.
?- T = (1+2) abc, write_canonical(T), nl.
Error: syntax error, operator expected unfinished input '.', user:1
?-
What surprised me is that even round brackets are unable to resolve this. Could be some stateful thing.
This may help:
?- write_canonical({(a).>} .>).
outputs(".>(.>(a))"), unexpected.
outputs(".>({}(.>(a)))"). % expected, but not found
Still getting...
$ tpl
?- op(9,yf,.>).
true.
?- write_canonical(a.> .>).
.>(a) true.
I'll look into it further.
?- writeq(a.> .>).
outputs("(a.> ).>"), unexpected.
outputs("a.> .>").
Well now it is a printing issue.
On Wed, 9 July 2025, 22:40 UWN, @.***> wrote:
UWN left a comment (trealla-prolog/trealla#667) https://github.com/trealla-prolog/trealla/issues/667#issuecomment-3052520709
?- writeq(a.> .>). outputs("(a.> ).>"), unexpected. outputs("a.> .>").
— Reply to this email directly, view it on GitHub https://github.com/trealla-prolog/trealla/issues/667#issuecomment-3052520709, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKSESX42LFBWUSF7N5PF33HUET5AVCNFSM6AAAAABWRFKSQSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTANJSGUZDANZQHE . You are receiving this because you commented.Message ID: @.***>
Please refer to the original quad:
?- writeq(((a) .>) .>).
outputs("a.>"), unexpected.
outputs("a.> .>"). % expected, but not found
The original was a parsing issue. That's fixed. Now the parens are a printing issue.
BTW, I noticed with Scryer...
$ scryer-prolog
?- op(9,yf,.>).
true.
?- X = a .> .> .
X = a.> .>. % This output can't be parsed back...
?- X = a .> .>.
.
error(syntax_error(incomplete_reduction),read_term/3:2).
?-
Posted. This is a top level issue which is out of scope (1Scope, Note f). And even portray_clause/1 handles this correctly in both Trealla and Scryer.
?- portray_clause(a.>).
a.> .