comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada.Real_Time.Time_Last
Date: Sun, 19 Nov 2017 12:50:56 +0200
Date: 2017-11-19T12:50:56+02:00	[thread overview]
Message-ID: <f7d60hFdm3cU1@mid.individual.net> (raw)
In-Reply-To: <wcch8trz0sf.fsf@TheWorld.com>

On 17-11-19 00:20 , Robert A Duff wrote:
> Niklas Holsti <niklas.holsti@tidorum.invalid> writes:
>
>> For various reasons, the developers of the Ada language have seen fit to
>> define in the RM some standard, predefined types for which they have
>> wanted to state the nature of the type, but not its full definition. For
>> example, we have, in package System,
>>
>>    subtype Any_Priority is Integer range implementation-defined;
>
> Yes, and Any_Priority'Last is a static expression.

Hm, I found no explicit statement on that in the RM. I assume it follows 
from the pragma Pure in package System, yes? On the other hand, there is 
an explicit requirement that Default_Bit_Order be static (RM 13.7(35/2)).

> Would it be static in your proposal?

I guess so; in this example, the proposal would only move the actual 
range expression to the private part, so I assume pragma Pure would have 
the same effect (enforce staticness) in the full declaration of the 
semi-private type.

> Programmers need to know the priority range in order to
> write pragmas Priority.  So in what sense is this
> "private" information?

Do you write, unportably:

    pragma Priority (42);

or do you write, as I do:

    Background_Prio : constant Priority := Priority'First;
    One_Herz_Prio   : constant Priority := Background_Prio + 1;
    etc.

and then write

    pragma Priority (Background_Prio);
    etc.?

>> This would enable all discrete-type operations on the Item type, but
>> would hide (keep private) what sort of discrete type it is, as well as
>> the names of the enumeration literals, if it is implemented as an
>> enumerated type. The RM defines just such a type in Ada.Interrupts:
>>
>>    type Interrupt_Id is implementation-defined;
>>
>> with the explanation (RM C.3.2(13)) "The Interrupt_Id type is an
>> implementation-defined discrete type used to identify interrupts."
>
> If Interrupt_Id is an enumeration type (not true for GNAT), you don't
> want to hide the names of the interrupts from clients.  If there's a
> Gizmo_Device_Interrupt, then clients want to attach handlers to that  by
 > name.

The RM defines the package Ada.Interrupts.Names for that (RM C.3.2(26)); 
it contains a set of definitions of constant Interrupt_Id objects, where 
both the names and values of those objects are "implementation-defined". 
This proposal would not change that, but these constants would probably 
become deferred constants, with their actual values in a private part.

For sure, this proposal is not going to remove all 
"implementation-defined" text from the RM. In my mind, that is not the 
goal of the proposal; the goal is to give packages more control over the 
amount of information they publish about their private types. For 
example, I have had cases where I wanted to publish the ability to use a 
private type as an array index type, without revealing much more about 
the type. The RM is only a good source of examples of types which 
should, perhaps, be semi-private in this sense.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

  reply	other threads:[~2017-11-19 10:50 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-15 14:28 Ada.Real_Time.Time_Last Simon Wright
2017-11-15 20:03 ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-17  9:20   ` Ada.Real_Time.Time_Last Simon Wright
2017-11-17 21:39     ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 13:06       ` Ada.Real_Time.Time_Last AdaMagica
2017-11-18 13:18         ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 14:00           ` Ada.Real_Time.Time_Last AdaMagica
2017-11-18 14:15           ` Ada.Real_Time.Time_Last Jeffrey R. Carter
2017-11-18 15:24             ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 16:01               ` Ada.Real_Time.Time_Last Dmitry A. Kazakov
2017-11-18 17:31                 ` Ada.Real_Time.Time_Last Niklas Holsti
2017-11-18 22:20               ` Ada.Real_Time.Time_Last Robert A Duff
2017-11-19 10:50                 ` Niklas Holsti [this message]
2017-11-20  5:57                 ` Ada.Real_Time.Time_Last J-P. Rosen
2019-01-29 22:03       ` Ada.Real_Time.Time_Last Simon Wright
replies disabled

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