Search code examples
smalltalkcovariancecontravariance

Java vs Smalltalk - covarince and contravariance


Does Smalltalk support covariance and contravariance? Do these concepts apply to this language?


Solution

  • Smalltalk is strictly and dynamically typed. It only cares if a parameter object responds to the messages it gets send. If not, it raises a DNU (Does Not Understand) at run time when the message is sent (which you can handle either by hand, or respond to in code). At compile time, every parameter is an object, and you are allowed to send any message to any object.