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!1.eu.feeder.erje.net!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!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: Mon, 03 Jul 2017 16:39:07 -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 1499114347 3428 192.74.137.72 (3 Jul 2017 20:39:07 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 3 Jul 2017 20:39:07 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:69Wg7oBrYlDRTFsrqsju4MoSq+8= Xref: news.eternal-september.org comp.lang.ada:47270 Date: 2017-07-03T16:39:07-04:00 List-Id: "Randy Brukardt" writes: > "Robert A Duff" wrote in message > news:wcca84q5vq1.fsf@TheWorld.com... >> Niklas Holsti writes: > ... >> 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. > > That's not the problem. The problem is knowing whether to call Finalize at > all. The only solution I could see for the GNAT approach is to treat all > tagged objects as controlled (using a null Finalize in cause the object > isn't controlled). That's expensive. In this fictional/future version of Ada, I presume the Tag of an object could only change if it's a class-wide object. So you don't have to finalize all tagged objects -- just class-wide ones, and that's essentially what GNAT is doing anyway. E.g. if you say: X : T'Class := F(...); the compiler doesn't know whether X contains controlled subcomponents, so it does a dispatching call to a compiler-generated primitive of T, which finalizes components, or does nothing. GNAT can optimize that away if you use the No_Finalization restriction. Maybe also the Disable_Controlled aspect on a type -- not sure about that. > For a list-based approach (like the one Janus/Ada uses), I don't see any > solution at all. Putting every tagged object on the finalization lists would > be prohibitively expensive. Again, not every tagged object, just every class-wide object. Actually, not even that. Just every class-wide object that uses this new feature. It would be known at the root of the type hierarchy whether Tags can change. So there's no distributed overhead. - Bob