# Backtracking global variables

**URL:** <https://swi-prolog.discourse.group/t/backtracking-global-variables/4234>\
**Category:** Request For Comments\
**Created:** [August 1, 2021, 3:21pm UTC](https://swi-prolog.discourse.group/t/backtracking-global-variables/4234 "2021-08-01T15:21:12Z")\
**Posts on this page:** 1\
**Page:** 1

<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:** [August 1, 2021, 3:21pm UTC](https://swi-prolog.discourse.group/t/backtracking-global-variables/4234/1 "2021-08-01T15:21:13Z")

</div>

Dealing with [Calling nb\_current with undefined global invokes user:exception hook · Issue #868 · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/issues/868), I decided to have a special _no value_ in global variables. This would also allow us that backtracking which takes us back to before the first b\_setval/2 to delete the variable rather than binding it to `[]`.

I’ve implemented this and, except for having to adjust the tests that verify resetting to `[]` this doesn’t seem to have any consequences for any of the other tests.

Deleting is obviously cleaner than resetting to `[]`. Is it worth the incompatibilities that may result from it?
