Version 1.3 of ais/ai-00441.txt

Unformatted version of ais/ai-00441.txt version 1.3
Other versions for file ais/ai-00441.txt

!standard 13.13.2 (04)          05-11-22 AI95-00441/02
!standard 13.13.2 (07)
!standard 13.13.2 (12)
!standard 13.13.2 (15)
!standard 13.13.2 (20)
!standard 13.13.2 (23)
!standard 13.13.2 (30)
!standard 13.13.2 (33)
!standard 13.13.2 (60)
!standard 3.09 (18)
!class amendment 05-10-24
!status Amendment 200Y 05-10-24
!status ARG Approved 7-0-2 05-11-19
!status work item 05-10-24
!status received 05-10-07
!priority High
!difficulty Easy
!subject Passing a null stream access value to stream attributes
!summary
The first parameter to the stream attributes is explicitly declared to be a not null access type.
!problem
Now that anonymous access types allow null values, the actual passed to a stream attribute can be null (whereas in Ada 95 it would have raised C_E on the call). The standard needs to say what happens in this case.
!recommendation
(See summary.)
!wording
Change the first parameter of each of the stream attributes to read:
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Change the last example in 13.3 to (note that this example is wrong anyway, Read is not a function!):
function My_Input(Stream : not null access Ada.Streams.Root_Stream_Type'Class) return T; for T'Input use My_Input; -- see 13.13.2
Change the first example in 13.13.2 to:
procedure My_Write( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : My_Integer'Base);
!discussion
The alternative of explicitly saying that null raises Constraint_Error was thought to be a kludge, given that the "not null" qualifier is available.
This qualifier is not an incompatiblity, as attributes only require mode conformance when they are specified. And both the old and new forms are mode conformant.
Note that Generic_Dispatching_Constructor is supposed to have a matching profile, so it is also changed.
!corrigendum 3.9(18)
Insert after the paragraph:
X'Tag
X'Tag denotes the tag of X. The value of this attribute is of type Tag.
the new paragraphs:
The following language-defined generic function exists:
generic type T (<>) is abstract tagged limited private; type Parameters (<>) is limited private; with function Constructor (Params : not null access Parameters) return T is abstract; function Ada.Tags.Generic_Dispatching_Constructor (The_Tag : Tag; Params : not null access Parameters) return T'Class; pragma Preelaborate(Generic_Dispatching_Constructor); pragma Convention(Intrinsic, Generic_Dispatching_Constructor);
Tags.Generic_Dispatching_Constructor provides a mechanism to create an object of an appropriate type from just a tag value. The function Constructor is expected to create the object given a reference to an object of type Parameters.
!corrigendum 13.3(85)
Replace the paragraph:
function My_Read(Stream : access Ada.Streams.Root_Stream_Type'Class) return T; for T'Read use My_Read; -- see 13.13.2
by:
function My_Input(Stream : not null access Ada.Streams.Root_Stream_Type'Class) return T; for T'Input use My_Input; -- see 13.13.2
!corrigendum 13.13.2(04)
Replace the paragraph:
procedure S'Write( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in T)
by:
procedure S'Write( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in T)
!corrigendum 13.13.2(07)
Replace the paragraph:
procedure S'Read( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out T)
by:
procedure S'Read( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out T)
!corrigendum 13.13.2(12)
Replace the paragraph:
procedure S'Class'Write( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in T'Class)
by:
procedure S'Class'Write( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in T'Class)
!corrigendum 13.13.2(15)
Replace the paragraph:
procedure S'Class'Read( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : out T'Class)
by:
procedure S'Class'Read( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : out T'Class)
!corrigendum 13.13.2(20)
Replace the paragraph:
procedure S'Output( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in T)
by:
procedure S'Output( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in T)
!corrigendum 13.13.2(23)
Replace the paragraph:
function S'Input( Stream : access Ada.Streams.Root_Stream_Type'Class) return T
by:
function S'Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class) return T
!corrigendum 13.13.2(30)
Replace the paragraph:
procedure S'Class'Output( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : in T'Class)
by:
procedure S'Class'Output( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : in T'Class)
!corrigendum 13.13.2(33)
Replace the paragraph:
function S'Class'Input( Stream : access Ada.Streams.Root_Stream_Type'Class) return T'Class
by:
function S'Class'Input( Stream : not null access Ada.Streams.Root_Stream_Type'Class) return T'Class
!corrigendum 13.13.2(60)
Replace the paragraph:
procedure My_Write( Stream : access Ada.Streams.Root_Stream_Type'Class; Item : My_Integer'Base);
by:
procedure My_Write( Stream : not null access Ada.Streams.Root_Stream_Type'Class; Item : My_Integer'Base);
!ACATS test
This should only require updates for existing tests.
!appendix

From: Gary Dismukes
Sent: Friday, October  7, 2005  12:32 PM

Now that anonymous access types allow null values, the actual passed
to a stream attribute can be null (whereas in Ada 95 it would have
raised C_E on the call).  It seems that the RM should explicitly
specify that a null stream access value passed to the default
implementation of a stream attribute must raise Constraint_Error.
One way to arrange this would be to change the access parameters
to be null-excluding, though that may raise questions of compatiblity
with existing stream attribute specifications, so it might be better
to simply state that the default implementation raises C_E if passed
a null stream access value.

*************************************************************

From: Tucker Taft
Sent: Friday, October  7, 2005  1:17 PM

I think I would vote for changing the spec on these, despite
the disruption to existing code.  During a transition period,
compilers could allow either, but this seems like a clear case
where we *don't* want the increased overhead on every use
of a stream operation having to worry about a possibly-null
access value.  Adding a comment that passing null will raise
a Constraint_Error seems like a definite kludge, given the
available of the "not null" qualifier.

Probably the right transition approach is for existing Ada 95
compilers to start allowing "not null" on access parameter
and access discriminant specifications, and effectively
ignoring them.  Once people get to Ada 2005, the transition
will hopefully already be well underway.

*************************************************************

From: Bob Duff
Sent: Friday, October  7, 2005  6:48 PM

Yes, I agree with Tuck.

*************************************************************

From: Pascal Leroy
Sent: Monday, October 10, 2005  4:22 AM

I agree with Tuck.

*************************************************************


Questions? Ask the ACAA Technical Agent