I'm used to dynamic typing meaning checking for type info of object/non object oriented structure at runtime and throwing some sort of type error, ie if it quacks like a duck its a duck. Is there a different type of dynamic typing (please go into details).
+1
A:
No, dynamic typing is when values have type but variables do not, so most type checking is done at runtime. So, basically, if the value walks or quacks like a duck, it's a duck, else an error is thrown. Duck typing really just describes a feature of dynamic typing that ensures it will be typesafe (i.e. a method will only run if variable foo
'has the right attribute or can execute that method).
Rafe Kettler
2010-08-01 14:45:49
That's incorrect. It doesn't check the type, only that the type can do some operator X or has some attribute Y. If you call, say, toString() on a variable, then if it is an object and it implements a toString() method, then it will be called, otherwise, you get an error. But many types could fulfill this requirement.
siride
2010-08-01 14:57:16
Good point, I'll make an edit
Rafe Kettler
2010-08-01 15:22:36