Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!GARGOYLE.UCHICAGO.EDU!bailey%candide From: bailey%candide@GARGOYLE.UCHICAGO.EDU (Stephen Wilson Bailey) Newsgroups: comp.lang.modula2 Subject: Re: Clever way to deal with this? Message-ID: <9002122258.AA07744@candide> Date: 12 Feb 90 22:58:42 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Modula2 List Organization: The Internet Lines: 42 TYPE BufType = RECORD length: CARDINAL; data: ARRAY [0..MAX(CARDINAL)] OF CHAR; END; BufPtrType = POINTER TO BufType; VAR mybuf: BufPtrType; (* * Somewhere in this code you either malloc * the buffer, or cast something to it. *) . . . PrintBuffer(mybuf); . . . PROCEDURE PrintBuffer(bptr: BufPtrType); VAR curchar: CARDINAL; BEGIN FOR curchar := 0 TO bptr^.length DO Write(bptr^.data[i]); END; END; -------------------------------------- If you don't trust your compiler to optimize away the de-reference, using ``WITH bptr^ DO'' will usually force the issue ('though not always. Personally, I leave it up to the compiler). You're right, it isn't handled as well as it could be. The WRL Modula-2 includes a ``flexible array'' extension for just this purpose. I assume Modula-3 has a comparable notion. Steph