Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

portray_clause/1 does not emit operators correctly #2715

Open
triska opened this issue Dec 17, 2024 · 2 comments
Open

portray_clause/1 does not emit operators correctly #2715

triska opened this issue Dec 17, 2024 · 2 comments

Comments

@triska
Copy link
Contributor

triska commented Dec 17, 2024

Example:

?- portray_clause(((-) :- (-),(-))).
- :-
   - ,
   - .
triska added a commit to triska/scryer-prolog that referenced this issue Dec 17, 2024
Examples:

    ?- portray_clause(((+) :- a=b,(-))).
    (+) :-
       a=b,
       (-).
       true.

    ?- portray_clause((a :- (b :- c))).
    a :-
       (b:-c).
       true.

This addresses mthom#2715.

Currently, more round brackets than needed are emitted. Ideally, a
better approach to solve the issue here and also in toplevel.pl is
found in the future.
@triska
Copy link
Contributor Author

triska commented Dec 21, 2024

#2714 addresses this.

@triska triska closed this as completed Dec 21, 2024
@UWN
Copy link

UWN commented Dec 21, 2024

Now:

?- portray_clause(//).
   outputs("(//).\n"), unexpected.
   outputs("// .\n"). % expected, but not found

Justification: "//" is an atom which is an operator and thus has priority 1201 (6.3.1.3). The whole text is a valid clause term (6.2.1.2) because the priority for a clause term is 1201, too. As of today, only GNU Prolog writes this correctly, SICStus uses round brackets. And ignoring those that do not write round brackets for (//):-(//) or just write invalid syntax.

@triska triska reopened this Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants