trealla icon indicating copy to clipboard operation
trealla copied to clipboard

Postfix difficulties

Open UWN opened this issue 9 months ago • 5 comments

?- 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

UWN avatar Feb 05 '25 14:02 UWN

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.

infradig avatar Feb 05 '25 21:02 infradig

More weirdness...

?- writeq(f(a) .>), nl.
a.>
   true.
?- 

infradig avatar Feb 05 '25 22:02 infradig

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
?- 

infradig avatar Feb 05 '25 22:02 infradig

What surprised me is that even round brackets are unable to resolve this. Could be some stateful thing.

UWN avatar Feb 06 '25 07:02 UWN

This may help:

?- write_canonical({(a).>} .>).
   outputs(".>(.>(a))"), unexpected.
   outputs(".>({}(.>(a)))"). % expected, but not found

UWN avatar Feb 06 '25 07:02 UWN

Still getting...

$ tpl
?- op(9,yf,.>).
   true.
?- write_canonical(a.> .>).
.>(a)   true. 

I'll look into it further.

infradig avatar Mar 13 '25 10:03 infradig

?- writeq(a.> .>).
   outputs("(a.> ).>"), unexpected.
   outputs("a.> .>").

UWN avatar Jul 09 '25 12:07 UWN

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: @.***>

infradig avatar Jul 09 '25 12:07 infradig

Please refer to the original quad:

?- writeq(((a) .>) .>).
   outputs("a.>"), unexpected.
   outputs("a.> .>"). % expected, but not found

UWN avatar Jul 09 '25 12:07 UWN

The original was a parsing issue. That's fixed. Now the parens are a printing issue.

infradig avatar Jul 09 '25 13:07 infradig

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).
?- 

infradig avatar Jul 09 '25 13:07 infradig

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.> .

UWN avatar Jul 09 '25 13:07 UWN