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!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: class wide iterable (and indexable) Date: Mon, 7 Jan 2019 09:28:18 +0100 Organization: Aioe.org NNTP Server Message-ID: References: <2a6929c5-72fa-4d84-953a-44ea4597ab38@googlegroups.com> <9e6b4219-d6ba-4c89-814d-5ea6e48ed8ea@googlegroups.com> <9179093f-4765-47a9-9dc6-147c9d7d6c56@googlegroups.com> <809a445d-cf73-4525-a732-67dbf24e8394@googlegroups.com> <1e4f3e15-afe4-4ca3-b039-11c6918f9977@googlegroups.com> NNTP-Posting-Host: i065DRYuysvTI4qVnaNkyg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 X-Notice: Filtered by postfilter v. 0.8.3 X-Mozilla-News-Host: news://news.aioe.org Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:55233 Date: 2019-01-07T09:28:18+01:00 List-Id: On 2019-01-06 22:58, George Shapovalov wrote: > Just on a small specifics here. > > On Sunday, January 6, 2019 at 9:18:09 PM UTC+1, Dmitry A. Kazakov wrote: >> You override getter and/or setter. Whatever representation of inherited >> bases stay unless overridden as a whole. The similar approach is used >> for discriminants: either extension or overhaul. (The latter case may >> not be limited, it must be strictly by-value) > So, out of 3 variants, you select the first one - to keep all things around and accumulate as you go, which *is* the safest, and probably the most sensible, way to do it. But this will not fly universally - what about situations where you have billions of copies of your record (all with different data). It is substitutability. In by-reference case you must keep the representation, no way around it. Thus, extension is the only way. This is the model used by Ada tagged types. In the by-value case you can replace the representation, but reconstruct it back when you substitute. There is no third option, except for making code adjustments according to the actual types. This is how class-wide operation work already. And there is no deep hierarchies, so billions of copies would be a great exaggeration. > Oh well, most developers will either be too scared to use that or will do nonsemsical things without proper understanding, leading to failed software and more possibilities for the rest of us to do things properly :). Software fails when developers strive to understand things they need not to while paying no attention to ones they must. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de