[Prev][Next][Index][Thread]

Re: type safety




Matthias,

    I agree that (static) typing and safety are orthogonal issues.
There doesn't seem to be a consensus about what "safety" means, though,
making this discussion difficult.

    My notion of safety is different from the ones discussed so far.
Safety to me means (roughly) that "programs cannot core-dump".  Or, to
be less Unix-specific, the formal language specification does not
contain the words "if X happens then the result is undefined."  (That
means to me that a correct compiler for that language is allowed to
generate code to erase your hard drive in that case...)

    Hence, a language where divide by zero is defined to produce an
exception that the programmer may catch, and whose programs are
specifically allowed to terminate with an uncaught exception would be
safe to me (assuming no other bad operations exist).  This is not to say
that the language wouldn't be very hard to write non-error-prone
programs in, just that the language itself is safe.
     
    I go back and forth on whether or not assembly language is safe.
I'm leaning at the moment toward saying that it is safe because
everything that can "go wrong" is implicitly part of the language spec.


    I consider Scheme to be dynamically typed, so I'd label your diagram
with "statically typed" rather then "typed" to make the distinction
between ML and Scheme.  BTW, I often see safety referred to as "strong
typing"; authors often confuse strong typing with static typing in the
way you complain about.

						- Mark Lillibridge