Right. We'll learn more about exceptions later, but the key idea now is that Ada normally detects errors as soon as they occur. If you're curious, the name of the exception this program will raise is "Constraint_Error".

Also, a quick note for GNAT Ada compiler users - at the time of this writing GNAT only detects this particular error (integer overflow) at run-time if you give it the "-gnato" option. There are plans for this to eventually become the default in GNAT; see the GNAT documentation for more information.

You may go to the next section.

You may also:

PREVIOUS Go back to the question

OUTLINE  Go up to the outline of lesson 1

David A. Wheeler (dwheeler@dwheeler.com)

The master copy of this file is at "http://www.adahome.com/Tutorials/Lovelace/s1sfr2.htm".