Subject: Re: Circular references

From: Jan Wielemaker <[email-masked]>
Date: Fri, 15 Sep 2000 17:30:53 +0200

On Fri, 15 Sep 2000, Paul Singleton wrote:
>"Richard A. O'Keefe" wrote:
> 
>> Cyclic terms are a big headache all over the place,
>
>For Prolog implementors maybe, but surely not intractable; and for
>application programmers surely they needn't be a headache at all?
>
>(I guess garbage collection is a big headache for implementors,
>and I'm thankful that it's theirs and not mine :-)

Actually the garbage collector is the simplest part and it works
on cyclic terms without knowing about them :-)

The problem is all functions that walk along terms have to be
aware of this.  Most naturally these are written as simple
recursive functions.  Like that they are short and simple to
read.  Over time, in SWI-Prolog most of these functions now
avoid the recursion on the right-most argument, so very
deep lists and other right-recursive structures can be handled
with limited stack-space.

True though that the current approach of a few functions dealing
with it, but most leading to a big crash isn't the most elegant.

	--- Jan