|
|
|
|
|
by ubernostrum
2793 days ago
|
|
This is not a characteristic of dynamic typing, some statically typed languages supports variable shadowing in the same scope. A dynamic (or hybrid) typing system is IMHO simply a system which provides a variant type as first class citizen. You're welcome to your humble opinion. Your opinion is not generally accepted, though. The most common definitions of static versus dynamic typing boil down to whether both names and values have types and those types must be compatible (static) or whether only values have types and no checking for compatibility with names is required (dynamic). That is: a = 3
a = 'foo'
The above probably fails in a statically-typed language, because 'a' will be a name of a type incompatible with the value 'foo'. In a dynamically-typed language it's perfectly OK. |
|
I am not sure that this is always correct. I am pretty sure that your example would be accepted in some static type systems with union types such as https://www.cl.cam.ac.uk/~sd601/papers/mlsub-preprint.pdf