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:

    The adolescent does not develop her identity and individuality by moving outside her family. She is not triggered by some magic unconscious dynamic whereby she rejects her family in favour of her peers or of a larger society.... She continues to develop in relation to her parents. Her mother continues to have more influence over her than either her father or her friends.
    Terri Apter (20th century)

    We must get back into relation, vivid and nourishing relation to the cosmos and the universe. The way is through daily ritual, and is an affair of the individual and the household, a ritual of dawn and noon and sunset, the ritual of the kindling fire and pouring water, the ritual of the first breath, and the last.
    —D.H. (David Herbert)

    I am prisoner of a gaudy and unlivable present, where all forms of human society have reached an extreme of their cycle and there is no imagining what new forms they may assume.
    Italo Calvino (1923–1985)

    A lover is never a completely self-reliant person viewing the world through his own eyes, but a hostage to a certain delusion. He becomes a perjurer, all his thoughts and emotions being directed with reference, not to an accurate and just appraisal of the real world but rather to the safety and exaltation of his loved one, and the madness with which he pursues her, transmogrifying his attention, blinds him like a victim.
    Alexander Theroux (b. 1940)