Ada 95 Quality and Style Guide | Chapter 10 |
10.5.4 Checking for Constraint Errorsguideline
Use hard-coded constraint checking when measured performance indicates. example
subtype Small_Int is Positive range Lower .. Upper; Var : Small_Int; ... -- Using exception handler Double: begin Var := 2 * Var; exception when Constraint_Error => ... end Double; -- Using hard-coded check if Var > Upper / 2 then ... else Var := 2 * Var; end if;rationale
Determine the impact of using exception handlers to detect constraint errors. If the exception handling mechanism is slow, then hard-coded checking may be more efficient.
< 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 |