A private part can be added to the predefined packages AI-00248/05 1 90-12-13 ra WA | !standard 14.03.10 (00) 90-12-13 AI-00248/05 !class ramification 90-02-01 | !status WG9-approved 90-12-07 !status ARG-approved 90-05-28 (reviewed) !status ARG-approved (10-0-1) (pending editorial review) !status work-item 90-02-01 !status received 84-05-14 !references 83-00358, 83-01339 !topic A private part can be added to the predefined packages !summary 90-02-01 An implementation can add a private part to any of the packages declared within TEXT_IO (or to any other predefined package). Except as specified by the Standard, implementations are not allowed to extend a predefined package by adding new declarations to its visible part. In particular, such extensions are not allowed for the package TEXT_IO or for any of the generic packages declared within this package. !question 90-04-20 The package TEXT_IO has a private part to allow an implementation to add any definitions it may need for a proper implementation of the specification. In particular, it could add a pragma INTERFACE for any subprograms implemented in some other language: typically this would be the systems language for a particular environment. But in order to provide similar implementations of the subprograms declared in the generic packages INTEGER_IO, FLOAT_IO, etc., an implementation needs to be able to add a private part to these packages. Is this allowed? Second, can additional declarations be added to the visible part of the TEXT_ IO package? This would be useful in providing Ada bindings to other standards. For example, since POSIX provides the notion of a standard error output stream (in addition to standard input and standard output), it would be appropriate to add the following to TEXT_IO implementations for POSIX/Ada: function STANDARD_ERROR return FILE_TYPE; Additionally, POSIX is concerned about the effects of buffering on input-output operations. Currently, the only way to force an implementation to flush the buffers associated with a file is to close the file. It would be useful if POSIX had the freedom to add operations to TEXT_IO that directly caused buffers to be flushed without having to close files: procedure FLUSH_BUFFER (FILE : in out FILE_TYPE); procedure FLUSH_ALL_BUFFERS; It is possible to declare these operations in a package outside of TEXT_IO, but then the subprogram bodies will not have access to the variables that need to be modified in order to flush the buffers. A private part can be added to the predefined packages AI-00248/05 2 90-12-13 ra WA So the two questions are: 1. Can an implementation add a private part to the generic packages declared in package TEXT_IO? 2. Can an implementation add subprograms to the visible part of TEXT_IO and any of its packages? !response 90-06-12 An implementation is allowed to add a private part to any of the predefined packages since such a private part cannot change the set of visible declarations required by the Standard. An implementation is not allowed to add additional visible declarations to the predefined packages except where specifically allowed by the standard. For example, implementations are allowed to add floating point type declarations to package STANDARD. However, pragmas and representation clauses affecting entities declared in the visible part of a predefined package can be placed in an implementation's private part. The predefined packages provide standard functionality across all implementations. It was not the intent to allow implementation-defined extensions. If an implementation wishes to provide an extended version of TEXT_IO or some other package, it can provide a complete extended version as a new package, e.g., POSIX_TEXT_IO. Such a package could contain all of the functionality of the standard TEXT_IO package plus extensions thought to be useful. Programmers could then use this extended package instead of the standard package if they need the additional functionality.