Ada 95 Quality and Style Guide | Chapter 8 |
8.2.2 Unconstrained Arraysguideline
Use unconstrained array types for array formal parameters and array return values.
Make the size of local variables depend on actual parameter size, where appropriate. example
... type Vector is array (Vector_Index range <>) of Element; type Matrix is array (Vector_Index range <>, Vector_Index range <>) of Element; ... --------------------------------------------------------------------- procedure Matrix_Operation (Data : in Matrix) is Workspace : Matrix (Data'Range(1), Data'Range(2)); Temp_Vector : Vector (Data'First(1) .. 2 * Data'Last(1)); ... ---------------------------------------------------------------------rationale
Unconstrained arrays can be declared with their sizes dependent on formal parameter sizes. When used as local variables, their sizes change automatically with the supplied actual parameters. This facility can be used to assist in the adaptation of a part because necessary size changes in local variables are taken care of automatically.
< Previous Page | Search | Contents | Index | Next Page > |
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC | TOC |
Appendix | References | Bibliography |