
In article <e5aek0$ikb$1@sea.gmane.org>, "Beman Dawes" <bdawes@acm.org> wrote:
"Ben Artin" <macdev@artins.org> wrote in message news:macdev-641F43.15244027052006@sea.gmane.org...
In article <e56qh0$lu2$1@sea.gmane.org>, "Maarten Kronenburg" <M.Kronenburg@inter.nl.net> wrote:
If you believe that every unsigned integer is an integer, you should read Effective C++. Item 35, "Make sure public inheritance models 'isa'"
In the 3rd edition, "Make sure public inheritance models 'isa'" is item 32.
Indeed.
until you stop believing it.
What specific operations are you saying that the integer class supports but C++ unsigned integer class doesn't support? Meyer's Bird/Penguin flying argument only applies if there are operations supported by integers but not by unsigned integers, AFAIK.
I am actually referring to the square/rectangle example, which is much more subtle. The point is that if A isa B then every invariant of B also has to hold for A. So, the question is then: are there any invariants on integers that do not hold on unsigned integers? It is not at all obvious to me that's true (especially since integer invariants have not yet, as far as I know, been stated explicitly), but the obvious place to look is subtraction and negation. If we are talking about infinite precision integers, then some example of reasonable invariants on integers that do not apply to unsigned integers might be: a + (-a) = 0 a - b + b = a Ben -- I changed my name: <http://periodic-kingdom.org/People/NameChange.php>