To view parent comment, click here.
To read all comments associated with this story, please click here.
There is no relation between dynamic/static typing and binding. The two are conflated because most statically-typed languages have "variable declarations" that serve the dual-role of creating a binding and assigning a type to a variable.
Your example actually just proves the point. You've shown an example of a statically typed language that creates bindings in assignments. We've previously seen examples of statically typed languages that don't create bindings in assignments (C), dynamically typed languages that don't (Dylan), and dynamically typed languages that do (Python), thus establishing the orthogonality of typing and binding creation.
To address the difference between dynamically-typed and statically-typed languages, it helps to consider the fully-general conception of a "variable". A variable is composed of three things: an entry in a symbol table, which points to a reference to an object, which points to an object. In practice, this chain is collapsed by the compiler, but that's behind the scenes stuff. In all strongly-typed languages, the object has a specific type. In statically-typed languages, the reference, too, has a specific type. A reference can only point to objects of the proper type. In dynamically-typed languages, a reference can point to objects of any type.
Now, where some languages make things interesting is what happens if you do:
b = 3.0;
In Dylan, this is perfectly legal, and has the function of setting the object pointed to by the reference pointed to by the binding 'b' to the object 3.0. In Boo, this may be either illegal (as in C), or legal, but for a different reason. If its legal in Boo, the line has the effect of changing the binding 'b' to point to a different reference, one which can point to an object of type 'float'.
What helps is to consider what happens when there is no binding directly to a variable, as in a structure, since this gets rid of the confusing aspect of changing the binding rather than the reference. A field in a structure has no entry in the symbol table, and hence no binding. If the following lines:
a.q = 1;
q.q = 3.0;
are legal, then you're dealing with a dynamically-typed language. If they're not, its a statically-typed language.
Edited 2006-09-03 20:46
Actually, that's legal in boo - numbers are rather flexible.
I do understand the actual difference between inferenced and dynamic, I just don't see what advantage the loss in speed gives you. I just see the disadvantage of reduced error checking.
Perhaps this is just the way I program, but I have never found a situation where dynamic typing would produce a more elegant solution than static typing.






Member since:
2005-09-11
What's the difference, then, between dynamic typing and inferenced static typing?
a = 0
b = 4
will not fail in Boo. Yet it's still static typing.