# Effefct of "write" option at the top-level

**URL:** <https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530>\
**Category:** General\
**Created:** [February 23, 2026, 11:42pm UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530 "2026-02-23T23:42:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [February 23, 2026, 11:42pm UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530/1 "2026-02-23T23:42:33Z")

</div>

Apologies if this has been explained before. I had a quick look around and could not find anything on the Discourse.

It used to be that pressing w for “write” at the top-level during backtracking would print out a list in its entirety.

```prolog
25 ?- l_systems:l_system(dragon_curve,l_systems,[f],6,O).
O = [f, +, g, +, f, -, g, +, f|…] [write]
O = [f, +, g, +, f, -, g, +, f|…] 
  Possible actions:
  ; (n,r,space,TAB): redo | t: trace&redo
  *: show choicepoint | . (c,a,RET): stop
  w: write | p: print
  +: max_depth*5 | -: max_depth//5
  b: break | h (?): help

Action? .

```

(This is with the latest daily build for windows (Mon Feb 23 05:17:53 2026) on a windows 11 machine.)

There’s a FAQ I could find on the SWI site, here:

> **[Help: I want the whole answer](https://www.swi-prolog.org/FAQ/AllOutput.html)**

This advises to press “+” at the top-level to increase the value of `the max_depth/1` option for the `answer_write_options` flag.

I think this is new, or I missed it before because I always pressed “w” to see an entire list. In any case, what does the “write” option do now? Is there any way to get back its old functionality?

---

<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:** [February 24, 2026, 7:47am UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530/2 "2026-02-24T07:47:58Z")

</div>

> [@stassa.p](#):
>
> I think this is new, or I missed it before because I always pressed “w” to see an entire list. In any case, what does the “write” option do now? Is there any way to get back its old functionality?

“w” and “p” switch between write and print, notably (de)activating portray/1 hooks. “+” and “-” increase or decrease the depth. There is no immediate “give me all”. Why would you want that though? Typing a few times “+” should give more context than what you are prepared to read, while it avoids flooding the terminal with an unmanageable amount of data.

There is no real way “back” except changing the code or adding a portray/1 rule that (conditionally) prints the whole thing as you want. I’m happy to reconsider that if there is enough need/interest.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [February 24, 2026, 1:36pm UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530/3 "2026-02-24T13:36:41Z")

</div>

> [@jan](#):
>
> “w” and “p” switch between write and print, notably (de)activating [portray/1](https://www.swi-prolog.org/pldoc/doc_for?object=portray/1) hooks. “+” and “-” increase or decrease the depth. There is no immediate “give me all”. Why would you want that though? Typing a few times “+” should give more context than what you are prepared to read, while it avoids flooding the terminal with an unmanageable amount of data.

Thanks. I often want to keep a record of a top-level session to a file with `protocol/1` which I then can search for the output I’m looking for. In that case I want to see the entire output and I don’t care if it floods the screen, that’s more or less the point.

> [@jan](#):
>
> There is no real way “back” except changing the code or adding a [portray/1](https://www.swi-prolog.org/pldoc/doc_for?object=portray/1) rule that (conditionally) prints the whole thing as you want. I’m happy to reconsider that if there is enough need/interest.

Part of my question is that I don’t understand what has changed. Clearly something has because in the past I could press “w” to see the entire output, without having to increase the context with “+”. I never had to add a `portray/1` hook to do that, it was the standard behaviour of the top-level.

Can you explain what changed? How did the top-level interpret “w” before, and how has that changed now? Why did I see the entire context with “w” before but I don’t see it now? What is the difference between “write” and “print” at the top-level?

Edit: or just point me to the relevant documentation, of course.

Thanks!

---

<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:** [February 24, 2026, 2:45pm UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530/4 "2026-02-24T14:45:02Z")

</div>

> [@stassa.p](#):
>
> Can you explain what changed?

Roughly, the commands (w/p/+/-) manage the Prolog flag `answer_write_options` and the answer is written using write\_term/3 using these flags. So, you can get unbounded output by setting this flag appropriately (omit `max_depth(N)`). As you probably activate protocol/1 somewhere, you could set this flag at the same time. That seems a sensible solution to your problem.

The built-in management of this flag is in print\_predicate/3 in `boot/toplevel.pl`.

What changed is how this Prolog flag is affected. `w` used to disable portrayed and max\_depth and `p` enabled these. Now they merely toggle portrayed, while max\_depth is modified with +/-. They are different features and combining these in one action is sometimes a bad choice. Also stepping max\_depth rather than using 10 vs infinite seems useful.

---

<div class="post-metadata">

**Author:** ![stassa.p](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/stassa.p/32/712_2.png) [@stassa.p](https://swi-prolog.discourse.group/u/stassa.p)\
**Post date:** [February 24, 2026, 3:51pm UTC](https://swi-prolog.discourse.group/t/effefct-of-write-option-at-the-top-level/9530/5 "2026-02-24T15:51:36Z")

</div>

Thanks for clarifying. I agree that separating the effects of w and + is a better choice.

I usually start `protocol/1` at the top-level, but I think I should be able to play around with the options of `write_term/3` to get back the behaviour I’m used to.
