From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d27da90d4e621e8d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-08 07:22:42 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!194.42.224.136!diablo.netcom.net.uk!netcom.net.uk!not-for-mail From: "Ayende Rahien" Newsgroups: comp.lang.ada Subject: Re: Problem understanding procedure Adjust(. Date: Sun, 8 Apr 2001 14:04:40 +0200 Organization: (Posted via) GTS Netcom - Public USENET Service http://pubnews.netcom.net.uk Sender: ayende@softhome.net Message-ID: <9aps7e$2g5$2@taliesin.netcom.net.uk> References: <9an4ru$al9$1@taliesin.netcom.net.uk> <3ACFCCC6.9B4C9162@acm.org> NNTP-Posting-Host: diup-180-26.inter.net.il X-Trace: taliesin.netcom.net.uk 986739760 2565 213.8.180.26 (8 Apr 2001 14:22:40 GMT) X-Complaints-To: abuse@corp.netcom.net.uk NNTP-Posting-Date: Sun, 8 Apr 2001 14:22:40 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.60.2296.0000 X-MimeOLE: Produced By Microsoft MimeOLE V5.60.2296.0000 Xref: supernews.google.com comp.lang.ada:6642 Date: 2001-04-08T14:04:40+02:00 List-Id: "Jeffrey Carter" wrote in message news:3ACFCCC6.9B4C9162@acm.org... > Ayende Rahien wrote: > > > > As far as I understand, this procedure [Adjust] is called if I do assignment on > > stacks (which is what this package is about). > > If I got it correctly, when I do: > > stack1 := stack2; > > The Adjust procedure will be called. > > To fully understand what happens here (assignment to a variable of a > controlled type), first Finalize is called with Stack1 as its actual > parameter ("Stack1 is finalized."). The Stack2's bit pattern is copied > into Stack1's memory space ("assignment"). Then Adjust is called with > Stack1 as its actual parameter ("Stack1 is adjusted."). > > So, it the stack type is implemented as a dynamically allocated linked > list, Finalize would free the list, one node at a time. After > assignment, both stacks would point at the same linked list. Adjust > would then make a deep copy of Stack2's linked list for Stack1 to point > at. Thanks, that help understanding it.