Subject: [clisp-list] CLISP 3-06-2000 evil behavior

From: David Allen <[email-masked]>
Date: Tue, 18 Apr 2000 20:09:32 -0400

I'm a bit new to Lisp, but I've got a problem which I absolutely
cannot imagine is the default behavior for a lisp.  When I do this, my
machine starts using 100% of the CPU and rapidly eating as much memory
as it can get its hands on, quickly filling all of my RAM and swap
space, and bringing the machine to its knees.

(I am fully aware that this problem may be due to my lack of knowledge
though, so if there is a silly reason this is happening, please let me
in on the secret)

Here's a transcript:
[3]> (defstruct treenode left right parent)
TREENODE
[4]> (setq root (make-treenode))
#S(TREENODE :LEFT NIL :RIGHT NIL :PARENT NIL)
[5]> (setq left1 (make-treenode))
#S(TREENODE :LEFT NIL :RIGHT NIL :PARENT NIL)
[6]> (setq right1 (make-treenode))
#S(TREENODE :LEFT NIL :RIGHT NIL :PARENT NIL)
[7]> (setf (treenode-left root) left1) 
#S(TREENODE :LEFT NIL :RIGHT NIL :PARENT NIL)
[8]> (setf (treenode-right root) right1)
#S(TREENODE :LEFT NIL :RIGHT NIL :PARENT NIL)

Now THIS line I wouldn't recommend putting in, since
it will cause the problem I'm talking about.
(setf (treenode-parent left1) root)

As you can probably see, I'm trying to build a tree-ish structure,
that should look like this:

               root
              /    \
           left1   right1

Which works fine, until I try to set left1's parent node to root.
That's how the tree is organized, and I know it's indirect
self-reference, but shouldn't CLISP be able to handle it?  When I issue
that statement, I'm guessing that it's having the same effect as if I
did:

(defun stupid-recursion (x)
   (stupid-recursion (cdr x)))
(stupid-loop nil)

(i.e. memory hogging recursion that is sans-basecase.)

Any help would be appreciated.
-- 
David Allen
http://opop.nols.com/
----------------------------------------
"Our bombs are smarter than the average high school student. At least they
can find Kuwait."
        -- A. Whitney Brown

---

From: Hannu Koivisto <[email-masked]>
Date: 19 Apr 2000 10:43:52 +0300

David Allen <[email-masked]> writes:

| I'm a bit new to Lisp, but I've got a problem which I absolutely
| cannot imagine is the default behavior for a lisp.  When I do this, my

Well, whether you can imagine it or not, it is the default
behaviour, and quite reasonable default behaviour indeed.  See
*PRINT-CIRCLE* if you want to change it.

-- 
Hannu