comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Ada.Real_Time.Time_Last
Date: Sat, 18 Nov 2017 17:24:35 +0200
Date: 2017-11-18T17:24:35+02:00	[thread overview]
Message-ID: <f7b1ljFtcmsU1@mid.individual.net> (raw)
In-Reply-To: <oupf9j$170$1@dont-email.me>

On 17-11-18 16:15 , Jeffrey R. Carter wrote:
> On 11/18/2017 02:18 PM, Niklas Holsti wrote:
>>>>
>>>>     type Count is private range <>;
>>
>> This proposal is meant to remove this problem, by letting the
>> programmer provide more information about the private type, in the
>> same way as information can now be provided about generic formal
>> types, to equip those types with predefined operators that can be used
>> in the generic.
>
> If by that you mean that all the operations available for a generic formal
>
>    type Count is range <>;
>
> are also available for this private type, then Count'First and
> Count'Last are available, and there's nothing private about the type at
> all. I can't see that this buys anything.

Making Count'First and Count'Last available is part of the goal of the 
extension, but the point is that the *expressions* that define their 
values would still be *private*, which means that the user of the type 
cannot (or is not meant to) depend on those expressions. The user can 
access the end result ('First, 'Last) but is not meant to depend on any 
other properties of those expressions.

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;

The RM could have said,

    type Priority is private;

but then the RM could not have easily expressed the fact that 
Any_Priority is divided into two sub-ranges, Priority and 
Interrupt_Priority, and the RM would have had to provide several 
operations on type Priority, for example relational operators, which are 
now implicitly provided by the parent type Integer.

The purpose of the proposal is to replace the "implementation-defined" 
in such definitions with some formal, legal expression that has the same 
effect. This would make it possible for SW developers to mark such 
"implementation-defined" things as private, while still keeping their 
code in legal Ada rather than semi-formal RM text.

Perhaps the difference is clearer in the case of a private discrete 
type, which could be written (aping the generic formal discrete type 
syntax) as:

    type Item is private (<>);   -- Not current Ada!

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."

I agree that this proposal does not provide major benefits, but on the 
other hand it seems to me that it does not require a whole lot of new 
compiler mechanisms -- the information available about such 
"semi-private" types would be the same as the information available 
about generic formal types.

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


  reply	other threads:[~2017-11-18 15:24 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             ` Niklas Holsti [this message]
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                 ` Ada.Real_Time.Time_Last Niklas Holsti
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