Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> the derived class itself (which has no way of knowing what invariants might be expected of it as part of base class code).

In principle, with a sufficiently-robust type system, the invariants expected by the base class would be encoded in the typing, and the derived class would only be able to narrow them.

(Of course, OOP languages tend to either be untyped or have insufficiently robust type systems for this; robust type systems are more frequently associated with functional languages.)



If the type system already trivially enforces your custom invariants, aren't the types defined by your classes already in it?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: