Article View: comp.lang.modula2
Article #4061Re: Recursively defined data types.
From: Mark William Hopkins
Date: Wed, 17 Feb 1988 03:35
Date: Wed, 17 Feb 1988 03:35
27 lines
1493 bytes
1493 bytes
In article <11100002@snail> carroll@snail.CS.UIUC.EDU writes:
>
> I still don't understand how you would reference a recursive
>data element that was far down in the structure. How would you parametrize
>the reference to, say, the 10th data field of a recursively defined type?
>Would you have to type in 10 "." operators, with the field names
>between them? And how would you handle variable depth references?
If Modula-2 had data type recursion, then roughly like this:
List would be defined by:
List = RECORD CASE Null:Boolean OF
TRUE: |
FALSE: Data:Atom;
Next:List
END
END;
<ACCESING THE TENTH ELEMENT OF THE LIST L:List>
ReadHead is declared to be of type List:
ReadHead := L;
FOR I := 1 TO 9 DO
ReadHead := ReadHead.Next
END;
RETURN ReadHead.Data;
Technical Details
Message-ID:
<4641@uwmcsd1.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!pasteur!agate!ig!uwmcsd1!csd4.milw.wisc.edu!markhReferences:
<4593@uwmcsd1.UUCP> <11100002@snail>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!rutgers!ames!pasteur!agate!ig!uwmcsd1!csd4.milw.wisc.edu!markh From: markh@csd4.milw.wisc.edu (Mark William Hopkins) Newsgroups: comp.lang.modula2 Subject: Re: Recursively defined data types. Summary: Referencing components of recursive data types. Message-ID: <4641@uwmcsd1.UUCP> Date: 17 Feb 88 03:35:24 GMT References: <4593@uwmcsd1.UUCP> <11100002@snail> Sender: daemon@uwmcsd1.UUCP Reply-To: markh@csd4.milw.wisc.edu (Mark William Hopkins) Organization: University of Wisconsin-Milwaukee Lines: 27