home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / modula2 / 1722 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  1.7 KB

  1. Path: sparky!uunet!psgrain!puddle!f590.n139.z1.fidonet.org!Sean.Wilson
  2. From: Sean.Wilson@f590.n139.z1.fidonet.org (Sean Wilson)
  3. Sender: ufgate@puddle.fidonet.org (newsout1.26)
  4. Newsgroups: comp.lang.modula2
  5. Subject: Re: JPI Compiler bug?
  6. Message-ID: <40648.2B5FB768@puddle.fidonet.org>
  7. Date: Thu, 21 Jan 93 11:21:10 PDT
  8. Organization: FidoNet node 1:139/590 - PMI BBS, Green Bay WI
  9. Lines: 34
  10.  
  11. m >   So, let's put it this way: What does
  12.  
  13. m >               ALLOCATE ( PointerVariable, SIZE( PointerVariable^ ) )
  14.  
  15. m >   really perform? What do you achieve with an NEW(PointerVariable) call? m >   Still assuming that PointerVariable points at some structured type such m >   as RECORD.
  16.  
  17. m >   Marcus
  18.  
  19. Assuming you have done a:
  20.  
  21.   FROM Storage IMPORT ALLOCATE;
  22.  
  23. The call:
  24.  
  25.     ALLOCATE ( PointerVariable, SIZE( PointerVariable^ ) );
  26.  
  27. Invokes a specific procedure to allocate a block of the specified size from the heap and return it for use in PointerVariable.
  28.  
  29. The NEW() operator provides some generalisation. It always needs a procedure called ALLOCATE() of the same formal type as Storage.ALLOCATE() but it doesn't impose any further restrictions.  Your XStorage.ALLOCATE() procedure can do what it likes.  It also reduces the chance of error in the stongly typed storage system, e.g: how many times have you typed:
  30.  
  31.   ALLOCATE(PointerVariable, SIZE(PointerVariable));
  32.  
  33. So by using NEW() you have some flexibility in choosing your storage management, plus added safety.  I typically use it in conjunction with debugging storage functions.
  34.  
  35. Best regards
  36.   Sean.
  37.  
  38. ___
  39.  X PQ-Under-Trial 2.15 X CA Raisins murdered!  Cereal Killer? Film at 11.
  40.  
  41.  
  42. --  
  43. uucp: uunet!m2xenix!puddle!139!590!Sean.Wilson
  44. Internet: Sean.Wilson@f590.n139.z1.fidonet.org
  45.