Article View: comp.lang.modula2
Article #4807Re: Recursive data types
From: Jelske Kloppenburg
Date: Mon, 08 May 1989 19:12
Date: Mon, 08 May 1989 19:12
31 lines
1367 bytes
1367 bytes
In article <5734@cs.Buffalo.EDU>, ugprussa@cs.Buffalo.EDU (Michal Prussak) writes:
> Wirth describes in his book "Algorithms and Data Structures" (from 1986)
> a recursive data type (p 173):
>
> TYPE
> ped = RECORD
> CASE known: BOOLEAN OF
> TRUE: name: ARRAY[1..10] OF CHAR |
> FALSE: father, mother: ped; <--- recursive fields
> END (* case *);
> END (* record *);
>
> ...
That can not work. How much space should be reserved for a variable
of such a type? The world is not as big!
To generate recursive data structures I use the following:
TYPE
LinkPTR = POINTER TO Link;
Link = RECORD
Text: String;
Count: CARDINAL;
Left, Right: LinkPTR
END;
and I think a similar example is in Wirth's book defining modula.
kloppenbrg@kmx.gmd.dbp.de
UUCP: kloppen@gmdzi
In real life: Jelske Kloppenburg
Technical Details
Message-ID:
<1046@gmdzi.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!mcvax!unido!gmdzi!kloppenReferences:
<5734@cs.Buffalo.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!mcvax!unido!gmdzi!kloppen From: kloppen@gmdzi.UUCP (Jelske Kloppenburg) Newsgroups: comp.lang.modula2 Subject: Re: Recursive data types Summary: Recursive data types with the help of pointers Message-ID: <1046@gmdzi.UUCP> Date: 8 May 89 19:12:17 GMT References: <5734@cs.Buffalo.EDU> Organization: GMD, Sankt Augustin, F. R. Germany Lines: 31