In a message dated Fri, 25 Aug 2006, Mark J. Reed writes:
I think the justification for Luke's POV is the number of operations
each class provides.   But my perspective agrees with Juerd -
subclasses can remove functionality as well as adding it, and I
definitely view "constant" as an add-on modifier, not a default that
has to be overridden.


Can someone suggest some reading I can do to understand how that works?
I can't wrap my head around the idea of subclasses removing functionality. Does this mean you can't write

  class Super { method something { ... } }

  sub foo (Super $bar) { $bar.something() }

and expect foo($obj) to work, because $obj might be:

  class Sub is Super { # remove .something--how does that happen? }

  foo($obj); # Boom!?

So what happens? Do you arrange somehow for polymorphism to be interrupted, so that the call to foo() acts as though there was a nonconformant type? Does foo() get scanned somehow to notice that .something() is getting called, and $obj doesn't support .something, so that bubbles up such that foo() can't be called in the first place? (If that's true, how do you do duck-typing, since duck-typing code almost by definition has branches that would call such invalid methods?)

I had been toying with writing some tests for the DBC blocks. But the idea of removing functionality from a subclass completely blows away my understanding of DBC, so I'd particularly like some reading to help me understand how DBC works in a language that lets you remove functionality.

Trey

Reply via email to