Type Safety - Relation To Other Forms of Safety

Relation To Other Forms of Safety

Type safety is ultimately aimed at excluding other problems, e.g.:-

  • Prevention of illegal operations. For example, we can identify an expression 3 / "Hello, World" as invalid, because the rules of arithmetic do not specify how to divide an integer by a string. As discussed below, strong typing offers more safety, but generally does not guarantee complete safety.
  • Memory safety
    • Wild pointers can arise when a pointer to one type object is treated as a pointer to another type. For instance, the size of an object depends on the type, so if a pointer is incremented under the wrong credentials, it will end up pointing at some random area of memory.
    • Buffer overflow - Out-of bound writes can corrupt the contents of objects already present on the heap. This can occur when a larger object of one type is crudely copied into smaller object of another type.
  • Logic errors originating in the semantics of different types. For instance, inches and millimeters may both be stored as integers, but should not be substituted for each other or added. A type system can enforce two different types of integer for them.

Read more about this topic:  Type Safety

Famous quotes containing the words relation to, relation, forms and/or safety:

    Light is meaningful only in relation to darkness, and truth presupposes error. It is these mingled opposites which people our life, which make it pungent, intoxicating. We only exist in terms of this conflict, in the zone where black and white clash.
    Louis Aragon (1897–1982)

    Unaware of the absurdity of it, we introduce our own petty household rules into the economy of the universe for which the life of generations, peoples, of entire planets, has no importance in relation to the general development.
    Alexander Herzen (1812–1870)

    I have always thought that one man of tolerable abilities may work great changes, and accomplish great affairs among mankind, if he first forms a good plan, and, cutting off all amusements or other employments that would divert his attention, make the execution of that same plan his sole study and business.
    Benjamin Franklin (1706–1790)

    The safety of the republic being the supreme law, and Texas having offered us the key to the safety of our country from all foreign intrigues and diplomacy, I say accept the key ... and bolt the door at once.
    Andrew Jackson (1767–1845)