views:

53

answers:

1

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
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
Good point, I'll make an edit
Rafe Kettler