Re:Type Systems (2004) [pdf]
by hyperpape on Thursday August 31, 2017 @08:45PM
(#15145271)
I believe that most type theorists will say that's not a type, since it is trivially unsound. Otherwise a Python program is typed, so far as the programmer sorta halfway thinks about types ("I can iterate over this") at some point.
[ Parent
| on HN ]
> it is trivially unsound
Why? (And what is the antecedent of "it"?)
The program containing the declaration is unsound because it doesn't preclude using the variable in ways inconsistent with the declaration.
Ah. In that case:
> that's not a type, since it is trivially unsound
You are misunderstanding what a type is. A type is just a subset of all of the possible data values in a language. Types by themselves don't do anything.
It doesn't count as an assignment of a type to a variable because it's trivially unsound. Are you happy with the rewording?
OK, but:
1. CL implementations are free to do static type analysis based on declarations (and some do) and they are also free to signal run-time errors if you assign a value not of the declared type (and some do).
2. Not all storage locations are variables, e.g.:
Welcome to Clozure Common Lisp Version 1.10-r16479M (DarwinX8664)!
? (setf a (make-array 10 :element-type '(unsigned-byte 32)))
#(0 0 0 0 0 0 0 0 0 0)
? (setf (aref a 0) 'foo)
> Error: FOO doesn't match array element type of #<VECTOR 10 type (UNSIGNED-BYTE 32), simple>.
The point is that focusing on "variables" makes tacit assumptions about programming languages that aren't necessarily true.