# The most stupid question about interactive SWI prolog

**URL:** <https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455>\
**Category:** Help!\
**Created:** [September 17, 2021, 12:45pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455 "2021-09-17T12:45:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![halloleo](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@halloleo](https://swi-prolog.discourse.group/u/halloleo)\
**Post date:** [September 17, 2021, 12:45pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/1 "2021-09-17T12:45:08Z")

</div>

I’m using: SWI-Prolog version 8.2.4.

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)

```prolog
?-
| _

```

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

```prolog
?- _

```

Any way to do this? Maybe I’m missing the obvious here…

---

<div class="post-metadata">

**Author:** ![halloleo](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@halloleo](https://swi-prolog.discourse.group/u/halloleo)\
**Post date:** [September 17, 2021, 12:59pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/3 "2021-09-17T12:59:13Z")

</div>

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

```prolog
- _

```

without the ugly _Unexpected end of clause_ error.

Not really important, I guess.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [September 17, 2021, 1:21pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/5 "2021-09-17T13:21:14Z")

</div>

> [@EricGT](#):
>
> ```prolog
> ?- 
> | .
> 
> ERROR: Stream user_input:287:6 Syntax error: Unexpected end of clause
> ?- 
> 
> ```

That works. The `| ` prompt is a _continuation_ prompt telling you the input is incomplete. So, you can just keep typing, e.g.

```prolog
?- <return>
| write(hello).
hello
true.
?- 

```

Another popular trick if you use , (comma) rather than . (dot) by accident is to add `true.`, e.g.,

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

---

<div class="post-metadata">

**Author:** ![dmchurch](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/dmchurch/32/3427_2.png) [@dmchurch](https://swi-prolog.discourse.group/u/dmchurch)\
**Post date:** [September 17, 2021, 1:23pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/6 "2021-09-17T13:23:23Z")

</div>

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 😄

---

<div class="post-metadata">

**Author:** ![halloleo](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@halloleo](https://swi-prolog.discourse.group/u/halloleo)\
**Post date:** [September 17, 2021, 1:42pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/7 "2021-09-17T13:42:34Z")

</div>

Ok, so I think the easiest to get out of the _continuation_ pormpt is typing `true.`:

```prolog
?-
|. true.

?- _

```

This makes me happy. 😄 Thanks for engaging in this maybe pointless question.

---

<div class="post-metadata">

**Author:** ![EricGT](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@EricGT](https://swi-prolog.discourse.group/u/EricGT)\
**Post date:** [September 17, 2021, 1:48pm UTC](https://swi-prolog.discourse.group/t/the-most-stupid-question-about-interactive-swi-prolog/4455/8 "2021-09-17T13:48:40Z")

</div>

If you are like me you will tire of typing `true.` often.

Try

```prolog
?- assert(t :- true).
true.

```

Then you can

```prolog
?- 
| t.
true.

```
