In the interactive REPL, how can I end a statement without evaluation? How can I get out of an additional return?
Often I am in the situation that I press “enter” on a empty line and then I don’t now how to get “nicely” out of it. It looks like this: ("_" represents the cursor)
?-
| _
Now typing just <RETURN> keeps me indented, typing . (dot) + <RETURN> brings up “ERROR: Stream user_input:720:6 Syntax error: Unexpected end of clause”, Ctrl-C doesn’t seem to help either.
I just want to get back to
?- _
Any way to do this? Maybe I’m missing the obvious here…
No, no, I have the rules in, say, hanoi.pl and consult it with [hanoi], but when playing with calling the predicates in the REPL I easily type a superfluous <RETURN> - and just would like to get out of the indented
That works. The | prompt is a continuation prompt telling you the input is incomplete. So, you can just keep typing, e.g.
?- <return>
| write(hello).
hello
true.
?-
Another popular trick if you use , (comma) rather than . (dot) by accident is to add true., e.g.,
?- write(hello),
| true.
hello
true.
?-
On some installations pressing ^C (control C) and a (abort) also works. It depends on the input method (plain terminal, GNU readline, BSD libedit, embedding in Emacs, ECliPSe, etc.).
I’ve had exactly the same thought, fyi! It’s something on my list for “when I have the chance to do something about it”. My usual solution is the (only slightly cleaner) ^C into the interrupt menu, then “a” to abort back to the toplevel. Advantage is, even if you had superfluous characters at the beginning of the previous line, they won’t get interpreted as a goal.
I would, however, like to make it possible to get back to a clean toplevel prompt more easily, so I’ll take that as a vote in that direction for when I’ve got some spare cycles