Pascal Costanza <[EMAIL PROTECTED]> writes: > - In a dynamically typed language, you can run programs successfully > that are not acceptable by static type systems.
This statement is false. For every program that can run successfully to completion there exists a static type system which accepts that program. Moreover, there is at least one static type system that accepts all such programs. What you mean is that for static type systems that are restrictive enough to be useful in practice there always exist programs which (after type erasure in an untyped setting, i.e., by switching to a different language) would run to completion, but which are rejected by the static type system. By the way, the parenthetical remark is important: If a language's definition is based on a static type system, then there are *no* programs in that language which are rejected by its type checker. That's trivially so because strings that do not type-check are simply not considered programs. > Here is an example in Common Lisp: > > ; A class "person" with no superclasses and with the only field "name": > (defclass person () > (name)) > > ; A test program: > (defun test () > (let ((p (make-instance 'person))) > (eval (read)) > (slot-value p 'address))) > > (slot-value p 'address) is an attempt to access the field 'address in > the object p. In many languages, the notation for this is p.address. > > Although the class definition for person doesn't mention the field > address, the call to (eval (read)) allows the user to change the > definition of the class person and update its existing > instances. Therefore at runtime, the call to (slot-value p 'adress) > has a chance to succeed. I am quite comfortable with the thought that this sort of evil would get rejected by a statically typed language. :-) -- http://mail.python.org/mailman/listinfo/python-list