[ Table of Contents ] [ Prev ] [ Chapter Overview ] [ Glossary/Index ]
As usual, we begin with some self-test questions. (Answers are listed below in
reverse order.)
Self-Test Questions
Click Q#-# to see answer |
Q3-1 |
What are the kinds of "association" that can be used
when writing actual parameters in a subprogram call? |
Q3-2 |
Does every case statement have a when others
alternative? |
Q3-3 |
What are the three kinds of iteration schemes used in loop
statements? |
Q3-4 |
Must every block statement have a declarative part? |
Q3-5 |
What are three things you need to know how to do when dealing
with user-defined exceptions? |
Q3-6 |
How many return statements are required in
functions and procedures? |
Q3-7 |
What are the two kinds of delay statement? |
|
Key points of this chapter
- An assignment statement involves the evaluation of an expression whose type must match
the type of the variable receiving the new value.
- A procedure is called by stating its name, along with a parenthesized list of actual
parameters. Each parameter has a mode: in, in out,
or out.
- A function is invoked by appearing in an expression, along with its list of actual
parameters. Every function has at least one return statement.
- Branching algorithms employ if statements and case
statements, which are similar to those of many languages. In a case
statement, all possible alternatives must be covered.
- There are three forms of the loop statement: the basic loop,
the for loop, and the while loop.
An exit statement can be used to jump out of a loop.
- A block statement can be used to localize variables used in a small region of text, or
to localize an exception handler.
- When an exception is raised, it should be handled by an exception
handler -- either locally or at some higher level to which the exception has been
propagated.
- A null statement does nothing. When an access variable has a null
value, it points to nothing.
- The goto statement is used to transfer control to a specified,
"labeled" location in the same executable part.
- Code statements are used to incorporate machine (assembly) code in an Ada program.
Self-Test Answers |
A3-7 |
The two kinds of delay statement are
the relative delay and the absolute delay statements. The form of the latter is "delay
until expression". |
A3-6 |
Every function must have at least one
return statement. Procedures are not required to have any. |
A3-5 |
In dealing with exceptions you
need to know how to declare them, raise them, and handle them. |
A3-4 |
No, both the declarative part of a
block statement and the exception handling part are optional. (It would be silly to have
neither, however.) |
A3-3 |
The three forms of loop statements are the
basic loop, the for loop, and the while loop. |
A3-2 |
No, every case statement is not required to
have a when others alternative. But, all possible choices must be
covered. |
A3-1 |
Named association, positional association
and a mixture of the two can be used in making subprogram calls. |
|
Click here to return to questions
|
Wrap-up Discussion
This chapter has provided examples of the different kinds of executable statements in
Ada -- except those relevant to concurrency and synchronization (covered in Chapter
6). A complete list is provided on the page Simple
and Compound Statements in Appendix A. Key terms included in the Glossary/Index
are:
The next chapter covers the types and subtypes of Ada, including both the built-in
variety and the techniques used in creating user-defined types. Material on the built-in
attributes is also provided.
[ Back to top of page ] [ Prev ] [ To next chapter
]