comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <jrcarter@acm.org>
Subject: Re: Problem understanding procedure Adjust(.
Date: Sun, 08 Apr 2001 02:28:32 GMT
Date: 2001-04-08T02:28:32+00:00	[thread overview]
Message-ID: <3ACFCCC6.9B4C9162@acm.org> (raw)
In-Reply-To: 9an4ru$al9$1@taliesin.netcom.net.uk

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.

-- 
Jeff Carter
"We call your door-opening request a silly thing."
Monty Python & the Holy Grail



  parent reply	other threads:[~2001-04-08  2:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-07 13:28 Problem understanding procedure Adjust( Ayende Rahien
2001-04-07 13:45 ` Mark Biggar
2001-04-07 13:51   ` Ayende Rahien
2001-04-08  2:28 ` Jeffrey Carter [this message]
2001-04-08 12:04   ` Ayende Rahien
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox