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-07 06:46:09 PST Path: supernews.google.com!sn-xit-03!sn-xit-01!supernews.com!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail Message-ID: <3ACF1A25.E059BCBC@home.com> From: Mark Biggar X-Mailer: Mozilla 4.76 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Problem understanding procedure Adjust(. References: <9an4ru$al9$1@taliesin.netcom.net.uk> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Sat, 07 Apr 2001 13:45:44 GMT NNTP-Posting-Host: 65.3.211.243 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 986651144 65.3.211.243 (Sat, 07 Apr 2001 06:45:44 PDT) NNTP-Posting-Date: Sat, 07 Apr 2001 06:45:44 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: supernews.google.com comp.lang.ada:6612 Date: 2001-04-07T13:45:44+00:00 List-Id: Ayende Rahien wrote: > And I'm trying to read this package's body > (http://adahome.com/Tutorials/Lovelace/genestac.adb) > My problem is with this procedure: > procedure Adjust(Object : in out Stack) is > -- ... > end Adjust; > > As far as I understand, this procedure 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. > > Now, Object seems to be the variable on the right side (stack2), if so, how > come that stack1 get a new copy of the contents of stack2, without stack2 > being affected? > Object is an in ou parameter, this mean that changes that are done inside > the procedure will persist after the procedure terminate, right? > So how do stack1 get a copy of stack2 without destroy stack2? No, Adjust is called on stack1, after a bitwise copy is made of stack2. The intent is that Adjust can do things like deep copies or reference count changes. > Another question, when using new, how do I find out if the memory allocation > was unsuccessful? I assume that an exception is raise, is this correct? If > so, what is it? STORAGE_ERROR