Home | Contact | Pricing | News | Partners | Mailing List | Site Map
Gnat Pro. Powerful tools. Frontline Support. Ada expertise.

Gem #34: Safe and Secure Software : Chapter 2, Safe Typing

Author: John Barnes

Abstract: This week’s gem is the second chapter of John Barnes’ new booklet:

Safe and Secure Software: An Introduction to Ada 2005.

Over the coming months, we will be publishing all thirteen chapters of the booklet. In the attachment at the bottom of Gem #30 you can access the contents and bibliography for the entire booklet. We hope you will enjoy the read!

« Previous Gem | Next Gem » | Gems Menu

Let’s get started…

Safe typing is not about preventing heavy-handed use of the keyboard, although it can detect errors made by typos!

Safe typing is about designing the type structure of the language in order to prevent many common semantic errors. It is often known as strong typing.

Early languages such as Fortran and Algol treated all data as numeric types. Of course, at the end of the day, everything is indeed held in the computer as a numeric of some form, usually as an integer or floating point value and usually encoded using a binary representation. Later languages, starting with Pascal, began to recognize that there was merit in taking a more abstract view of the objects being manipulated. Even if they were ultimately integers, there was much benefit to be gained by treating colors as colors and not as integers by using enumeration types (just called scalar types in Pascal).

Ada take this idea much further as we shall see, but other languages still treat scalar types as just raw numeric types, and miss the critical idea of abstraction, which is to distinguish semantic intent from machine representation. The Ada approach provides more opportunities for detecting programming errors.

Read Chapter 2 in full

Note: All chapters of this booklet will, in time, be available on the Ada 2005 home page.

application/pdf
699.7Kb
 

Posted by Posted in Development Log, Ada / Ada 2005, Devt log - Gem of the Week

Have your own idea for a Gem?

If you have an idea for a Gem you would like to contribute please feel free to contact us at: gems@adacore.com

Discussion

2 responses to “Gem #34: Safe and Secure Software : Chapter 2, Safe Typing”


  1. Anh Vo said:

    John Barnes is one of my favorite authors.

    The second line of the example at the bottom of page 8 contains syntax error. That is attribute ‘Range should not be applied to an object of a scalar type.

    Throw: Integer range 2 .. 12;
    Counters: array (Throw’Range) of Integer;
    ^^^^^^^^^^^


  2. Peter Hermann said:

    The subtype version on the next page conforms to
    the current standard. John Barnes had Ada 2015 in mind.

Leave a Reply