🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #1974

Re: How to write NEW?

#1974
From: G Murray
Date: Sun, 21 Apr 1991 09:05
31 lines
1684 bytes
In article <5122672@janhh.hanse.de> jan@janhh.hanse.de (Jan Willamowius) writes:
> It looks like Wirth is using different ways to allocate memory
> in different versions of his books. Sometimes he uses
> 'Allocate(Var,SIZE(Type)' and sometimes 'NEW(Var)'.
> 
> I like the second way better, but my compiler only supports Allocate.
> So, is there a way to write a NEW (and DISPOSE, of course) ?>

 [Code Deleted]
 
> The problem is that p 'looses' its type in the conversion to ADDRESS and
> only a WORD is Allocated (ADDRESS is POINTER TO WORD).


  I don't think that you will be able to do it. NEW and DISPOSE are normally
built in functions, that require ALLOCATE and DEALLOCATE to be IMPORTed. In
my experience the compiler normally translates calls to NEW and DISPOSE into
appropriate calls to ALLOCATE and DEALLOCATE. So, without this 'inside
information' available to the compiler, I don't think that a library function
will be able to do it. 

Graham Murray				email gmurray@ibmpcug.co.uk
Senior Programmer			      gmurray@cix.compulink.co.uk
Gravatom Technology Ltd			voice +44 329 823986


-- 
Automatic Disclaimer:
The views expressed above are those of the author alone and may not
represent the views of the IBM PC User Group.
-- 
Technical Details
Message-ID: <1991Apr21.090546.28272@ibmpcug.co.uk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!slxsys!ibmpcug!gmurray

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!slxsys!ibmpcug!gmurray
From: gmurray@ibmpcug.co.uk (G Murray)
Newsgroups: comp.lang.modula2,connect.audit
Subject: Re: How to write NEW?
Message-ID: <1991Apr21.090546.28272@ibmpcug.co.uk>
Date: 21 Apr 91 09:05:46 GMT
Organization: The IBM PC User Group, UK.
Lines: 31