Version 1.1 of acs/ac-00122.txt

Unformatted version of acs/ac-00122.txt version 1.1
Other versions for file acs/ac-00122.txt

!standard 13.13.2(52/2)          05-10-24 AC95-00122/01
!class Amendment 05-10-24
!status received no action 05-10-24
!status received 05-10-13
!subject Stream 'Read and private scalar types
!summary
!appendix

From: Tucker Taft
Date: Thursday, October 13, 2005  5:25 AM

Here is an interesting problem we encountered
recently.  We have a limited private type, and
we want to define a visible 'Read attribute on it.
But it turns out the full type is a scalar type.
That requires us to define the attribute using
the base subtype.  How are these two things are
incompatible.  The 'Base attribute cannot be
used on a private type, but the 'Base attribute
must be used on a scalar 'Read attribute.

Is the 'Base requirement waived for types with
a partial view that is not scalar?  Should it
be?

Example:

     type Lim is limited private;
     procedure Read(S : access Root_Stream_Type'Class; Obj : out Lim);
     for Lim'Read use Read;

private

     type Lim is new Positive;
     -- Oops, Lim'Read is not defined on Lim'Base as is required
     -- by 13.13.2(51/2) (or the old paragraph 38)

I suppose my instinct would be to fix 50/2 and 51/2 so that they
require the base subtype unless there is a partial view that is
non-scalar, in which case they require the first subtype.
Not pretty, but at least well defined.

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

From: Pascal Leroy
Date: Friday, October 14, 2005  5:53 AM

I guess I don't see the problem.  I have always assumed that 13.13.2(51/2)
was checked using the properties that you see at the place of the
attribute_definition_clause.  At this place Lim is not scalar, so you must
use the first subtype.  I don't see how you would get an error later on
the completion, which is what your example seems to indicate.

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

From: Tucker Taft
Date: Friday, October 14, 2005  6:51 AM

Ok with me, though perhaps an AARM note would be helpful.
I wonder what happens if you have a non-limited private type T,
where the implicit 'Read on the partial view presumably has
parameter subtype T, while the 'Read on the full view,
presuming it is scalar, has parameter subtype T'Base.
The placement of the attribute definition clause, if any, seems
even more critical in that case, since using your suggested
rule, you must specify a Read procedure with T or T'Base
depending on where the attribute definition clause is.

I suppose I also wonder about specifying the 'Read on
a type derived from a formal private type T.  Do we require
a recheck on instantiation that the actual type is *not*
scalar?  Is it impossible to specify 'Read for such
a type?

I would be tempted to change the rule to *allow* the
use of the first subtype always for 'Read, while also
allowing the use of the base subtype if the associated
type is scalar.  That way the user can choose whether to
provide an operation that can handle values outside the
first subtype.  Since the rules no longer require the
stream_size to accommodate the base range, requiring its
use in the specification of the 'Read attribute seems
unnecessary.

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


Questions? Ask the ACAA Technical Agent