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

Toplevel answers for long strings are not correct #2676

Open
triska opened this issue Dec 3, 2024 · 4 comments
Open

Toplevel answers for long strings are not correct #2676

triska opened this issue Dec 3, 2024 · 4 comments

Comments

@triska
Copy link
Contributor

triska commented Dec 3, 2024

Currently, we get:

?- Ls = "This is a rather long string which is shortened by the toplevel.".
   Ls = "This is a rather lo ...".

The answer suggests that Ls is "This is a rather lo ...", but that is not true.

Shortening of long strings must be done in such a way that it is clear that this is not the actual solution.

The suggestion is to take inspiration from Ciao, using || to separate the shown prefix from the ellipsis.

Example:

?- Ls = "This is a rather long string which is shortened by the toplevel.".
   Ls = "This is a rather long s"||... .

Such an answer cannot be pasted back, which is the point.

@bakaq
Copy link
Contributor

bakaq commented Dec 3, 2024

Really stupid idea, but what about:

?- Ls = "This is a rather long string which is shortened by the toplevel.".
   phrase(("This is a rather long s",...), Ls).

It's more general than the query, but can be pasted back (assuming library(dcgs) is loaded).

@hurufu
Copy link
Contributor

hurufu commented Dec 4, 2024

Another solution would be to display truncated strings similarly to other lists:

?- Ls = "This is a rather long string which is shortened by the toplevel.".
   Ls = ['T',h,i,s,' ',i,s,' ',a,' ',r,a,t,h,e,r,' ',l,o|...].

@UWN
Copy link

UWN commented Dec 4, 2024

... phrase(("This is a rather long s",...), Ls).

Pasting this back results in a non-terminating query. So if at all, it would be rather phrase("This is a rather long s",Ls,...). which assumes that DCGs have been loaded.

@UWN
Copy link

UWN commented Dec 6, 2024

Some examples of double bar notation:

?- L="a"||"b"||"c".
   L = "abc".

?- L=""||""||""||K.
   L = K. 

?- L=("")||K.
   syntax_error(...).

?- L=[]||K.
   syntax_error(...).

Also, it would be now possible to split a string into multiple lines by still allowing
some layout inbetween.

   p( "this here\n"||
        "some more").

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

4 participants