Dynamic input without duck printing?

I'm used to a dynamic character set by checking the type of information about an object-non-object-oriented structure at runtime and throwing some kind of type error, i.e. if she dodges like a duck, her duck. Is there another type of dynamic typing (please go into the details).

+7
duck-typing dynamic-typing
source share
2 answers

Yes, absolutely. Duck-typing is an idiom that states that the type of value at a given time is based on the fields and methods that it has right now. Dynamic typing only suggests that types are associated with run-time values, and not with static variables and parameters. There is a difference between them, and you can use the latter without them.

For example, if you programmed in PHP and limited yourself to basic types without using OO, then you would use dynamic typing without using duck input.

+5
source share

No, dynamic typing is when values ​​are of type but no variables, so most type checks are performed at run time. Thus, basically, if value goes or dodges like a duck, it is a duck, otherwise an error occurs. Duck print does describe a dynamic input function that guarantees that it will be typical (i.e., the Method will only be executed if the variable foo has the correct attribute or can execute this method).

+1
source share

All Articles