🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #456

Re: MetCom (IT'S A WARNING!!!!)

#456
From: D.S. Cartwright
Date: Wed, 13 Dec 1989 11:05
48 lines
1716 bytes
UK4H@DKAUNI2.BITNET (JAE) writes:

>Bob Campbell wrote:
>> NEW is ALLOCATE(x,SIZE(x))
>> DISPOSE is DEALLOCATE(x,SIZE(x))
>THIS IS WRONG!!!!
>Instead you have to write
>  ALLOCATE(x,SIZE(x^));
>  DEALLOCATE(x,SIZE(x^));
>'^' is the caret (dereferencing 'operator').

The way I do it is thus: 

If you have a type declaration 

	TYPE
		Dave = POINTER TO Fred ;
		Fred = RECORD
			Field1 : ARRAY[0..30] OF INTEGER ;
			Field2 : ARRAY[0..9] OF CHAR ;
			Pointer : Dave ;
		       CEND ;

then	VAR
		Variable : Dave ;

	you can then do

	ALLOCATE (Variable,TSIZE(Fred))

	where ALLOCATE is IMPORTed from STORAGE and TSIZE from SYSTEM (or the
	other way round, I think this is the right way though).

One thing you have to make sure of is that you put TSIZE(Fred) and not, by a
slip of the keyboard, TSIZE(Dave), else you'll be trying to place something of
RECORD type in a space the size of a POINTER. Doesn't work, and it's a sod to
find out why (I know !!!!).

Just a thought .....

	Dave Cartwright,
	    School of Information Systems,
		University of East Anglia,
		    Norwich,
			England.

Note : I am only a student => I am pretty thick really => Don't shout at me too
							  much if I'm wrong.
Technical Details
Message-ID: <1044@sys.uea.ac.uk>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!mcsun!ukc!sys.uea!cmp8118
References: <"89-12-11-21:03:38.02*UK4H"@DKAUNI2.BITNET>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!wuarchive!zaphod.mps.ohio-state.edu!usc!ucsd!ucbvax!bloom-beacon!eru!luth!sunic!mcsun!ukc!sys.uea!cmp8118
From: cmp8118@sys.uea.ac.uk (D.S. Cartwright)
Newsgroups: comp.lang.modula2
Subject: Re: MetCom (IT'S A WARNING!!!!)
Message-ID: <1044@sys.uea.ac.uk>
Date: 13 Dec 89 11:05:10 GMT
References: <"89-12-11-21:03:38.02*UK4H"@DKAUNI2.BITNET>
Organization: UEA, Norwich, UK
Lines: 48