Lecture #3 – September 3, 2007
We briefly reviewed the printout
of Use_Date_with_output.adb
All instantiations
for reading and writing are of the form:
package
identifier is new ada.text_io.type_io (data type);
We remembered that
you can’t execute a package body.
We learned that in month_type’first the
apostrophe is read as “tick” and that ’first
and ’last are attributes of an enumerated type (such
as month_type) as are ’succ and ’pred.
We learned that
the last element in an enumerated type definition has no successor (’succ) and that the first element in an
enumerated type definition has no predecessor (’pred)
We changed the
enumerated list of months in date.ads and recompiled play_with_enumerated_types.adb to
use the new version but didn’t have to change anything in it.
We expanded on
procedure play_with_enumerated_types.adb by adding exception handling
We learned how to
handle two different kinds of errors: constraint_error and
data_error.
We learned that data_error is
in the ada.io_exceptions package and needs a
with statement
We discussed the
three types of loop statements and learned how to use the Ada95 reference
manual (see excerpt below)
We saw that the
loop control variable of a for loop may not be modified by the programmer
within the loop
We saw that if we
have a variable declared as i outside a for loop and the loop control
variable is also an i, then the two variables are independent
and the i outside the loop is only accessible
outside the loop and the loop control variable i
is only accessible inside the loop.
We learned that
exception handlers go at the end of a block; that they can be embedded in a
loop but then the loop should have a begin and an end in addition to
the loop … end loop
We learned that
you can have multiple exception handlers together in a procedure
but each follows a
when => statement and the word exception
only appears once in that case.