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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!.POSTED!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada Annoyances Date: Thu, 29 Jun 2017 17:29:10 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1ac5a44b-4423-443a-a7bb-2864d9abe78f@googlegroups.com> <4921bd4e-3827-a7ac-7f2d-d60edbc514a3@tidorum.invalid> NNTP-Posting-Host: shell02.theworld.com Mime-Version: 1.0 Content-Type: text/plain X-Trace: pcls7.std.com 1498771750 12791 192.74.137.72 (29 Jun 2017 21:29:10 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 29 Jun 2017 21:29:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:YdWFNAiePKrJv27kV3Lps/VNxP0= X-Received-Bytes: 2675 X-Received-Body-CRC: 1262408114 Xref: news.eternal-september.org comp.lang.ada:47194 Date: 2017-06-29T17:29:10-04:00 List-Id: Niklas Holsti writes: > Isn't finalization of local objects usually implemented by creating a > list of these objects, and then traversing that list on scope exit? No. That method was used originally by GNAT, but it was changed to a simpler and much more efficient method. Consider a record with defaulted discriminants. The set of components of that record that have finalization can change when the discriminant changes. That's complicated if you're keeping lists of those components. If you want to see how GNAT does it now, use the -gnatDGL switch to compile some examples. Look for procedures ending in "DI" ("deep initialize") and "DF" ("deep finalize"). Lists are used only for heap objects that need finalization, and not for their subcomponents. >...It > seems to me that changing the tag of an object on the list should not be > a problem; the new tag would just lead to a different Finalize, through > normal dispatching. I agree, I don't see a problem here. When Finalize is called, it dispatches via the currrent Tag. Tags can't change in Ada, but if they could it would still dispatch via the Tag value present when Finalize is called. > But perhaps there are other implementations where the particular > Finalize operation for a local object is determined when the > local-object declaration is elaborated, and therefore corresponds to the > initial tag value? I don't know of any such. - Bob