3 ms·
>It's like code expecting rectangles wouldn't mind to get squares, but a code expecting squares will definitely do mind getting rectangles. It is actually not
by kukx 9y ago
>It's like code expecting rectangles wouldn't mind to get squares, but a code expecting squares will definitely do mind getting rectangles.
It is actually not that obvious since in OOP neither a square or a rectangle type is properly a subtype of the other. [0]
I understand how implementation-wise it could be convenient to treat a function as a closure. Although, I would prefer some other type, eg:
functoid := closure | function
[0] - https://stackoverflow.com/questions/1030521/is-deriving-square-from-rectangle-a-violation-of-liskovs-substitution-principle https://stackoverflow.com/questions/1030521/is-deriving-squa...