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!reader02.eternal-september.org!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada.Real_Time.Time_Last Date: Sat, 18 Nov 2017 17:24:35 +0200 Organization: Tidorum Ltd Message-ID: References: <591a9389-a4b8-43fa-b963-0ebb9e488be1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net pFk8GXTeLO5Ux9kNG5BZAgZrrMBaJ0Hsx/ZTCJ55GQte0RD77l Cancel-Lock: sha1:lNrgsAMRG2A3SBUtzeilPqwzYcY= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: Xref: feeder.eternal-september.org comp.lang.ada:48990 Date: 2017-11-18T17:24:35+02:00 List-Id: 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 . @ .