From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Calling inherited primitive operations in Ada Date: Thu, 1 Sep 2022 23:33:44 +0200 Organization: A noiseless patient Spider Message-ID: References: <67b32db0-c4db-466c-ac13-e597e008c762n@googlegroups.com> <401d6f59-2c28-4dd5-9fa6-fccf33b6d645n@googlegroups.com> <12cc33b1-2c39-4057-8a03-623064b06e8en@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 1 Sep 2022 21:33:44 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="6a715631b025ee876628b22ef6a76d67"; logging-data="2416525"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19/jZVpX7mz0XgH68H91rFXvlXXeaUvZ04=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Cancel-Lock: sha1:ZJoVCqHmDA8Ry81O3euG2LfzLF0= Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64262 List-Id: On 2022-09-01 20:54, Emmanuel Briot wrote: > > generic > type Element_Type is private; > type Stored_Type is private; > package Elements is > end Elements; > > with Elements; > generic > type Element_Type is private; > package Definite_Elements is > package Traits is new Elements (Element_Type, Stored_Type => Element_Type); > end Definite_Elements; > > with Definite_Elements; > generic > type Key_Type is private; > package Maps is > package Keys is new Definite_Elements (Key_Type); > function "=" (L, R : Keys.Traits.Stored_Type) return Boolean -- "Stored_Type" is not a visible entity of "Traits" > is (False); > end Maps; As presented, this seems very over complicated. Elements and Definite_Elements add no value, and this is just a complex way of writing generic type Key is private; package Maps is function "=" (L : in Key; R : in Key) return Boolean is (False); end Maps; One hopes that the actual library makes better use of these pkgs than this small example. > This is not case where the actual is visible unless I happen to know how Definite_Element is implemented and that it will use Element_Type for Stored_Type (and this is not a knowledge I wish client packages to have, the whole point of Element and Definite_Element is to basically hide how elements can be stored in a container, and whether we need memory allocation for instance). Ada has excellent features for hiding, but these are not among them. Assuming that pkg Keys serves some actual role in the spec of Maps, then someone wanting to use pkg Maps will need to understand that role, which involves understanding Definite_Elements, which involves understanding pkg Traits, which involves understanding Elements. Rather than hiding anything, you are effectively requiring your users to look at these things, even if you could use the notation in question. -- Jeff Carter "[M]any were collected near them, ... to enjoy the sight of a dead young lady, nay, two dead young ladies, for it proved twice as fine as the first report." Persuasion 155