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: Sun, 19 Nov 2017 12:50:56 +0200 Organization: Tidorum Ltd Message-ID: References: <591a9389-a4b8-43fa-b963-0ebb9e488be1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net spuubVum0xhOZ8vA68v6SgeGylJ3Yi2liTvYSrxMxqWZFV+Bp7 Cancel-Lock: sha1:psEFwjpngdnY3aDAYtpmeV+Ph8w= 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:49003 Date: 2017-11-19T12:50:56+02:00 List-Id: On 17-11-19 00:20 , Robert A Duff wrote: > Niklas Holsti 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 . @ .