Chapter 13

Interlude: The S by C Controversy

When men understand what each other mean, they see, for the most part, that controversy is either superfluous or hopeless.

—Cardinal Newman: Sermon at Oxford (1839)

This chapter is heavily based on Appendix F (“A Closer Look at Specialization by Constraint”) of the Manifesto book. However, it does also contain quite a lot of new material.

Over the past few chapters, I’ve relied heavily on our ellipses and circles example; in particular, I’ve relied on the mathematical fact that an ellipse is a circle if and only if its semiaxis lengths a and b are equal. In terms of our inheritance model, what this means is that if an invocation of the ELLIPSE selector produces an ellipse with a = b, then specialization by constraint (S by C) comes into play and the result of that invocation is in fact of type CIRCLE.

As noted in Chapter 8, however, not everyone agrees with us on these matters. In fact, arguments have raged for years in the literature (especially the object literature) over exactly the ellipses and circles example. By way of illustration, consider the following quote from Section 23.4.3.1 of Bjarne Stroustrup’s book The C++ Programming Language (3rd edition, Addison-Wesley, 1997):

[In] mathematics a circle is a kind of an ellipse, but in most programs a circle should not be derived from an ellipse or an ellipse derived from a circle. The often-heard arguments “because that’s the way it is in mathematics” and “because the representation ...

Get Type Inheritance and Relational Theory now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.