It is MHO that there should be no difference in semantics based on the difference between the static and the dynamic type of objects. It's just a source of confusion.
I think this kind of polymorphism is best addressed through inheritance
and overriding than via the type system itself.
How do you mean that static dispatch (in "being more specific") differs from dynamic dispatch?
When do you actually want the option to dispatch to a less specific implementation?
Actually, is not the other way around entirely? Given the below example I think it is pretty clear that we want the implementation that can make the most assumptions about its input.
I'm more concerned with the covariant case. Should we not select the implementation that has the least constraints on what it produces?
The type argument can be seen as our interface to the imported module. A contravariant argument represent what we commit to provide, the covariant what we expect in return.
So by committing as much as possible to the input and relax regarding the output we maximize the modules freedom to act while still providing what we need.
If I explicitly request a foo producer why would I want the one that can only produce bars? F.ex I might need a test case producer, in this case I want it to be free to produce all relevant cases, not only an arbitrary subset.
If I explicitly request a foo producer why would I want the one that can only produce bars? F.ex I might need a test case producer, in this case I want it to be free to produce all relevant cases, not only an arbitrary subset.
Wow, I would love to see this get SIP'd. I like the direction of this much more than what I saw the last few times reforming implicit resolution with variance came up.
----------------------------------------
This message is intended exclusively for the individual(s) or entity to
which it is addressed. It may contain information that is proprietary,
privileged or confidential or otherwise legally exempt from disclosure.
If you are not the named addressee, you are not authorized to read,
print, retain, copy or disseminate this message or any part of it.
If you have received this message in error, please notify the sender
immediately by e-mail and delete all copies of the message.
Wow, I would love to see this get SIP'd. I like the direction of this much more than what I saw the last few times reforming implicit resolution with variance came up.