[comp.lang.ada] question re semantics of Ada length clause

howell@BOARDWALK.MITRE.ORG (Chuck Howell) (08/05/90)

I am unclear about (among many other things :-) the required semantics
of part of 13.2 of the Ada LRM.  Specifically, when an application uses
a length clause to specify the collection size for an access type
(13.2(b)), it's not clear to me that this is anything other than a
"highwater mark" guide to the runtime.  For example, an implementation
that grabs sections of storage for collections from the heap on demand
cannot a priori ensure that the requested amount of storage is
available, correct?  In that case, what is the implication of the phrase
"specifies the number of storage units to be reserved for the
collection"?

If setting T'Storage_Size for an access type collection does not ensure
that I won't get Storage_Error before I've used that many storage
units for that collection at runtime, does it at least provide some
check that what I've requested is potentially realizable?  In other
words, if I compile 
    for Some_Access_Type'Storage_Size use 1;
where 1 is not enough for even one allocation, should I get a warning
that Storage_Error will be raised? 
If I compile
    for Some_Access_Type'Storage_Size use 1000000;
where an attempt to actually allocate 1 Million storage units would
raise Storage_Error, should I expect a warning?
Neither VADS nor DEC ACS give compile warnings in either situation.
Since there is no explicit requirement in the Ada LRM for compilers to
provide such warnings for the use of 'Storage_Size, what does this
particular length clause provide?  Just some "informative" guidance to
the compiler?

Thanks for any insight provided,
    Chuck


+------------------------------------------------------------------------+
| Chuck Howell, M/S Z645     INTERNET: howell@community-chest.mitre.org  |
| The MITRE Corporation           OR   howell@mwunix.mitre.org           |
| 7525 Colshire Drive                                                    |
| McLean VA 22102-3481            FAX: (703) 883-5519                    |
+------------------------------------------------------------------------+

grover@brahmand.Eng.Sun.COM (Vinod Grover) (08/06/90)

In article <9008042114.AA11484@boardwalk.mitre.org.mitre.org> howell@BOARDWALK.MITRE.ORG (Chuck Howell) writes:
>check that what I've requested is potentially realizable?  In other
>words, if I compile 
>    for Some_Access_Type'Storage_Size use 1;
>where 1 is not enough for even one allocation, should I get a warning
>that Storage_Error will be raised? 
Even more interesting is the following:

    for access_type'storage_size use 0;

This is useful in cases where one is doing low-level programming and has
created an access type as an alternative view of another type, say
system'address. In this case one is never going to allocate any objects from
the collection for the access type, and would like not to reseverve storage
for the collection.

jbg@sei.cmu.edu (John Goodenough) (08/06/90)

The following approved AI specifies answers to some of your questions.
Regarding warning messages, the Standard does not require them, but an
implementation is allowed to provide them.

John B. Goodenough					Goodenough@sei.cmu.edu
Software Engineering Institute				412-268-6391

!standard 13.02    (08)                                 90-07-06  AI-00558/03
!class binding interpretation 88-04-26
!status WG9-approved 90-06-15
!status ARG-approved (10+1-1-1) 89-10-25 (by ballot)
!status ARG-approved (9-0-1) 89-02-27 (pending letter ballot)
!status work-item 88-04-26
!topic Specifying a collection size

!summary 89-11-14

A collection size specification cannot be rejected at compile time just
because the specified collection size is too large.  If insufficient space
is available, STORAGE_ERROR must be raised when elaborating the length
clause. 

If a positive storage size is specified, an implementation must allocate at
least the specified amount of space; reasonable "rounding up" of the
specified amount is allowed, where reasonable is to be understood in terms
of the implementation's usual algorithm for allocating space.  The rounding
algorithm must be specified in Appendix F. 

No space beyond the initial allocation can be provided by an
implementation. If an attempted allocation of a designated object would
exceed the amount of remaining unallocated space, an implementation must
raise STORAGE_ERROR. 

If the specified storage size is zero or negative, no storage is reserved
for the collection.   

-- 
John B. Goodenough					Goodenough@sei.cmu.edu
Software Engineering Institute				412-268-6391