Path: 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 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