\documentstyle[urg]{article} \begin{document} \issueno{0011} % This should always be 4 digits. \version{1} % This should be an integer. \date{89-04-20} % This is included for the index only. % The editor, uiref and airef are optional. Thus if you do not define them, % they will not appear in the title. \editor{Robert Dewar} %\airef{key AI references, if relevant} % All references to AI here and in the document should have the form % AI-xxxxx where x is a digit (5 digits) %\uiref{other UI references, if relevant} % All references to UI here and in the document should have the form % UI-xxxx where x is a digit (4 digits) % The following are not optional and will appear in the title. They have all % been given default values so as to prevent LATEX from raising errors. \title{Records with Dynamic Arrays} \section{3.7.1} \history{Discussed at Phoenix, March 1988; no vote} \shorteditor{R.Dewar} \shorttitle{Records with Dynamic Arrays} \status{Await revision} % create and print the documents title (i.e. all the above) \maketitle % The remaining sections are constructed using the following environments \begin{issue} There are two implementation techniques for dynamic arrays in unconstrained records. One allocates the maximum size all the time, the other uses a hidden pointer and allocates the actual required size on the heap. Which of these two implementations is preferable? Should a uniform choice between these two approaches be encouraged? \end{issue} \begin{recommendation} \end{recommendation} \begin{discussion} Consider the declarations: \begin{verbatim} type VTEXT (LEN : INTEGER := 0) is record CHARS : STRING (1 .. LEN); end record; VSTRING : VTEXT; \end{verbatim} If an implementation takes the approach of always allocating the maximum space, then the declaration of {\tt VSTRING} is likely to fail and raise {\tt STORAGE\_ERROR}. On the other hand if the implementation uses a hidden pointer and allocates the {\tt CHARS} value on the heap, then the declaration succeeds (initially allocating space for a null {\tt STRING}). The hidden pointer approach is more complex, since it requires special care on assignments to make sure that the old value is freed. On other other hand it does allow declarations such as the one above to succeed. The maximum size approach leads to a more consistent implementation of storage allocation. In favor of this approach is the argument that the heap should not be used without the programmers knowledge (particularly important if there are garbage collection implications in a real time situation), and that if the programmer wants a pointer, the effect can easily be achieved with an explicit declaration of an access value. Right now there are examples of both approaches among implementations, and it is a clear case where portability problems are being unnecessarily introduced. An informal survey of vendors providing portable Ada packages at one SIGAda meeting suggests that this a major problem in practical applications. Should the uniformity guidelines suggest a preferred approach? One approach is to require compilers to provide both operations with some kind of mechanism, possibly a pragma, to specify which approach is required. Of course the uniformity requirement would also have to specify the form of the pragma in this case. A possibly milder form would be to pick one of the two approaches and require it to be implemented, leaving it up to the compiler whether the other approach is required. \end{discussion} \begin{practice} There are validated compilers taking both approaches. No compilers provide a pragma selectable option. It is interesting to note that all the implementations for the IBM PC use the dynamic heap allocation approach, indicating that implementation limitations are not the motivating factor for the decision. Indeed this appears to be a case in which two opposed philosophies have developed. \end{practice} \end{document}