From: Ed Symanzik
Subject: structures
Date: 
Message-ID: <3DDBFF25.2050405@msu.edu>
I was trying to write a moo-like program and ran into
this problem.  I want things to have a location and I
want places to have a list of contents.  Seemed simple
enough.

(defstruct thing name location)
(defstruct place name contents)

So, make one of each.

(setf daniel (make-thing :name "Daniel"))
(setf closet (make-place :name "Closet"))

And put Daniel in the closet.

(setf (thing-location daniel) closet)
(setf (place-contents closet) daniel)

Oops.  Adding Daniel to the contents list throws clisp
and cmucl for a loop.  I could put daniel in the 'closet
but I don't expect everything should have a symbol
associated with it.

Would someone please point me in the right direction.

Thanks.

(This is a personal learning exercise, not classwork.
  I'd take a class if it were offered around here.)

From: Barry Margolin
Subject: Re: structures
Date: 
Message-ID: <dyTC9.25$qY1.2009@paloalto-snr1.gtei.net>
In article <················@msu.edu>, Ed Symanzik  <···@msu.edu> wrote:
>I was trying to write a moo-like program and ran into
>this problem.  I want things to have a location and I
>want places to have a list of contents.  Seemed simple
>enough.
>
>(defstruct thing name location)
>(defstruct place name contents)
>
>So, make one of each.
>
>(setf daniel (make-thing :name "Daniel"))
>(setf closet (make-place :name "Closet"))
>
>And put Daniel in the closet.
>
>(setf (thing-location daniel) closet)
>(setf (place-contents closet) daniel)
>
>Oops.  Adding Daniel to the contents list throws clisp
>and cmucl for a loop.  I could put daniel in the 'closet
>but I don't expect everything should have a symbol
>associated with it.

You said that the contents should be a *list*, but you just set it to
a single structure.  Try:

(setf closet (make-place :name "Closet" :contents '()))
(push daniel (place-contents closet))

Also, make sure you have *PRINT-LEVEL* set to a small number, so that the
printer doesn't give a fit when it tries to print them (because they're
mutually recursive).

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Martti Halminen
Subject: Re: structures
Date: 
Message-ID: <3DDC0201.7D30E882@kolumbus.fi>
Ed Symanzik wrote:
> 
> I was trying to write a moo-like program and ran into
> this problem.  I want things to have a location and I
> want places to have a list of contents.  Seemed simple
> enough.
> 
> (defstruct thing name location)
> (defstruct place name contents)
> 
> So, make one of each.
> 
> (setf daniel (make-thing :name "Daniel"))
> (setf closet (make-place :name "Closet"))
> 
> And put Daniel in the closet.
> 
> (setf (thing-location daniel) closet)
> (setf (place-contents closet) daniel)
> 
> Oops.  Adding Daniel to the contents list throws clisp
> and cmucl for a loop.  I could put daniel in the 'closet
> but I don't expect everything should have a symbol
> associated with it.


(setq *print-circle* T)

--