The most common error in writing and using overloaded operators in Ada is to
misunderstand when the operator must be placed in quotation marks. Quotation
marks are required if the operator is used in prefix form (e.g.,
Currency."+"(C1,C2)
) and not permitted if the operator is used in
infix form (e.g., C1 + C2
). Infix form is of course allowed only
in the presence of a USE
or USE TYPE
statement to
eliminate the need for qualification.
In writing an exception handler for a package-defined exception, do not forget
that the exception name must be qualified unless a USE
is present,
for example,
EXCEPTION WHEN Dates.Date_Error =>
A common design error in writing ADTs is to put too much in the specification. Often an ADT has extra functions or procedures in the body that are used only by other operations in the body and not intended to be used by client programs. Putting specifications for these in the package specification provides them to the client, whether or not this was intended.
Copyright © 1996 by Addison-Wesley Publishing Company, Inc.