comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Calling inherited primitive operations in Ada
Date: Thu, 1 Sep 2022 23:33:44 +0200	[thread overview]
Message-ID: <ter8fo$29nsd$1@dont-email.me> (raw)
In-Reply-To: <dad4c041-142f-4bb3-a51e-d7236996c529n@googlegroups.com>

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

  reply	other threads:[~2022-09-01 21:33 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-31  8:15 Calling inherited primitive operations in Ada Emmanuel Briot
2022-08-31 17:11 ` DrPi
2022-08-31 19:13 ` Dmitry A. Kazakov
2022-09-01  6:56   ` Emmanuel Briot
     [not found]     ` <67b32db0-c4db-466c-ac13-e597e008c762n@googlegroups.com>
2022-09-01 10:02       ` Dmitry A. Kazakov
2022-09-01 11:59       ` Jeffrey R.Carter
2022-09-01 12:37         ` Dmitry A. Kazakov
2022-09-01 13:37           ` Jeffrey R.Carter
2022-09-01 14:10             ` Emmanuel Briot
2022-09-01 15:50               ` amo...@unizar.es
2022-09-01 16:03               ` Jeffrey R.Carter
2022-09-01 16:07                 ` Emmanuel Briot
2022-09-01 16:17                   ` Jeffrey R.Carter
2022-09-01 18:54                     ` Emmanuel Briot
2022-09-01 21:33                       ` Jeffrey R.Carter [this message]
2022-09-02  6:11                         ` Emmanuel Briot
2022-09-02 10:55                           ` Jeffrey R.Carter
2022-09-02 11:20                             ` Emmanuel Briot
2022-09-02 14:28                               ` Jeffrey R.Carter
2022-09-03  0:16                               ` Randy Brukardt
2022-09-03  0:07                           ` Randy Brukardt
2022-09-03  8:59                             ` Jeffrey R.Carter
2022-09-07  0:42                               ` Randy Brukardt
2022-09-03 19:00                             ` Simon Wright
2022-09-05  6:56                               ` Emmanuel Briot
2022-09-05  7:34                                 ` Dmitry A. Kazakov
2022-09-05  9:30                                 ` Jeffrey R.Carter
2022-09-07  0:51                                 ` Randy Brukardt
2022-09-02  8:35                         ` amo...@unizar.es
2022-09-02  8:48                           ` Dmitry A. Kazakov
     [not found]                             ` <9484a755-f55d-407e-a40b-92421b0bcafbn@googlegroups.com>
2022-09-02  9:55                               ` Dmitry A. Kazakov
2022-09-02 10:41                           ` Jeffrey R.Carter
2022-09-02 11:04                             ` Dmitry A. Kazakov
2022-09-03  0:12                               ` Randy Brukardt
2022-09-03  8:23                                 ` Dmitry A. Kazakov
2022-09-03  0:01                           ` Randy Brukardt
2022-09-05  8:53                             ` amo...@unizar.es
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox