Path: utzoo!utgpu!water!watmath!clyde!rutgers!mailrus!nrl-cmf!ames!amdcad!sun!decwrl!labrea!csli!kasper From: kasper@csli.STANFORD.EDU (Kasper Osterbye) Newsgroups: comp.lang.modula2 Subject: Re: Recursively defined data types. Message-ID: <2420@csli.STANFORD.EDU> Date: 17 Feb 88 18:06:51 GMT Reply-To: kasper@csli.UUCP (Kasper Osterbye) Organization: Center for the Study of Language and Information, Stanford U. Lines: 37 Dear Mark, Recursive datatypes are not pointers in disguise. If I am not wrong, they will only represent trees - and here is why. I will assume your definition of a list. List = RECORD CASE Null:BOOLEAN OF TRUE : | FALSE: Key: ...; Data: ....; Next: List; END now assume that we have variables l1,l2 of type "List", and that l1 is (a,b,c). the magic of the concept recursive datatypes is that it is not pointers so when I do a l2 := l1; l2 gets assigned a COPY of l1, and if you change anything to l1, it will not affect l2. further more, an assignment of the form: l1.next.next := l1 will not give you a cycle, but rather the list (a,b,a,b,c). That is at least how I learned recursive types. As to your changed syntax for pointers so they pretend they are recursive, I dislike it, it looks different, but you will still have to learn the concept of pointers to use it. The why not use pointers afterall? /Kasper