Path: utzoo!attcan!uunet!husc6!encore!xenna.UUCP From: soper@xenna.UUCP (Pete Soper,,,) Newsgroups: comp.lang.pascal Subject: Re: Pointers.. Message-ID: <7476@xenna.Encore.COM> Date: 2 Jun 89 03:19:30 GMT References: <1150@draken.nada.kth.se> Sender: news@Encore.COM Lines: 21 From article <1150@draken.nada.kth.se>, by d87-jse@nada.kth.se (Joakim Sernbrant): > Talking about pointers, is there any reason why I shouldn't do this on > a PC running DOS without multitasking: > > while p <> nil do begin > dispose(p); > p := p^.next; > end; Yes. You might want your program to have a chance to make you rich and famous by being portable. A great many heap managers (like ours) would invalidate p after the dispose so the link assignment would blow up. Why can't you put up with an extra assignment to avoid this? Whether it is your unspecified DOS Pascal compiler or whatever, the overhead of a dispose would likely overwhelm the cost of an extra assignment that avoided dereferencing p after it had been disposed. ---------------------------------------------------------------------- Pete Soper +1 919 481 3730 arpa: soper@encore.com uucp: {bu-cs,decvax,necntc}!encore!soper Encore Computer Corp, 901 Kildaire Farm Rd, bldg D, Cary, NC 27511 USA