On 5/25/2017 6:38 PM, Andrey Andreev wrote:
> Sorry, but by "source" I didn't mean somebody state it here. :)
> 
> When I said I don't claim to fully understand LSP, I didn't mean "tell
> me what it is" - I'm familiar with it. What I don't understand is how
> do we get from this:
> 
>> Wikipedia:
>>
>> an object of type T may be substituted with any object of a subtype S
> 
> 
> To this:
> 
>> A single type may be substituted by any other type
> 
> 
> Cheers,
> Andrey.
> 

Hey Andrey!

Do not mix the LSP with type variance on arguments or return types. The
LSP is targeting subtyping directly. The quoted sentence refers to the
fact that S is not allowed to behave differently than T. I think you get
a better understanding if you read the "A typical violation" part of the
Wikipedia article.

The problem we are dealing with is variance of method arguments (and
return values). The corresponding Wikipedia article is here:

https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)

Specifically contravariant arguments:

https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)#Contravariant_method_argument_type

Hope this helps to clarify things. :)

-- 
Richard "Fleshgrinder" Fussenegger

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to