# Tabling doesn't work in 8.4.0?

**URL:** <https://swi-prolog.discourse.group/t/tabling-doesnt-work-in-8-4-0/4754>\
**Category:** Help!\
**Created:** [December 13, 2021, 3:49pm UTC](https://swi-prolog.discourse.group/t/tabling-doesnt-work-in-8-4-0/4754 "2021-12-13T15:49:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![snarfed](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/snarfed/32/3895_2.png) [@snarfed](https://swi-prolog.discourse.group/u/snarfed)\
**Post date:** [December 13, 2021, 3:49pm UTC](https://swi-prolog.discourse.group/t/tabling-doesnt-work-in-8-4-0/4754/1 "2021-12-13T15:49:43Z")

</div>

Hi all! I’m new to Prolog, I’m using SWI-Prolog version 8.4.0. on Mac OS X, installed via Homebrew. I’m trying to use tabling, but it doesn’t seem to be working. When I enter the example code from [SWI-Prolog -- Manual](https://www.swi-prolog.org/pldoc/man?section=tabling-non-termination) with `table connection/2.` uncommented and run the example query, it hits the 1GB stack space limit. Any idea what I’m doing wrong?

```prolog
$ cat test.prolog 
cat test.prolog 
table connection/2.

connection(X, Y) :-
        connection(X, Z),
        connection(Z, Y).
connection(X, Y) :-
        connection(Y, X).

connection('Amsterdam', 'Schiphol').
connection('Amsterdam', 'Haarlem').
connection('Schiphol', 'Leiden').
connection('Haarlem', 'Leiden').
$ swipl test.prolog 
Welcome to SWI-Prolog (threaded, 64 bits, version 8.4.0)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- connection('Amsterdam', X).
connection('Amsterdam', X).
ERROR: Stack limit (1.0Gb) exceeded
ERROR: Stack sizes: local: 0.9Gb, global: 48.4Mb, trail: 0Kb
ERROR: Stack depth: 6,340,760, last-call: 0%, Choice points: 6,340,753
ERROR: Probable infinite recursion (cycle):
ERROR: [6,340,760] user:connection('Amsterdam', _12681974)
ERROR: [6,340,759] user:connection('Amsterdam', _12681994)
   Exception: (6,340,759) connection('Amsterdam', _12681904) ? a
a
% Execution Aborted
?- 

```

---

<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:** [December 13, 2021, 3:53pm UTC](https://swi-prolog.discourse.group/t/tabling-doesnt-work-in-8-4-0/4754/2 "2021-12-13T15:53:04Z")

</div>

> [@snarfed](#):
>
> `table connection/2.`

Must be `:- table connection/2.` Note the `:-`, turning this into a _directive_ to the compiler rather than a clause.

---

<div class="post-metadata">

**Author:** ![snarfed](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/snarfed/32/3895_2.png) [@snarfed](https://swi-prolog.discourse.group/u/snarfed)\
**Post date:** [December 13, 2021, 3:54pm UTC](https://swi-prolog.discourse.group/t/tabling-doesnt-work-in-8-4-0/4754/3 "2021-12-13T15:54:41Z")

</div>

Thank you!!! That did the trick indeed.
