Now that I've read ahead to 3.4, the "multi method solution" shown can be a little simpler, just need to add "multi" to the original "equal" methods, see attached.
-y On Tue, Jun 30, 2015 at 4:16 PM, yary <not....@gmail.com> wrote: > Section 3.2's example does not fail for the given reason "This tries to > access the c instance variable of the argument $b thus yielding a > run-time error" - instead Perl6 more correctly complains that it was > expecting a ColPoint, but got a Point instead. Indeed one cannot generally > replace a subtype with its parent type, only the other way around. Can > correct by re-writing along the lines of "This fails to dispatch because > ColPoint's equal method requires a ColPoint argument, but we are calling > it with the supertype Point, which does not compose with the method's > signature." > > (Furthermore if "equal" is defined as a "multi method," then the > dispatcher chooses Point's "equal" method, and the example returns > "True," which all looks good to me. But it doesn't illustrate the paper's > point.) > > -y > >
Point.p6
Description: Binary data