Re: Types for Perl 6: request for comments

[email protected] (yary)
Newsgroups perl.perl6.language
Message-ID <CAG2CFAaR++TO8mM8W1nek_S6Dv79rSRhZTx4Dn+9-2PsS+i5fQ@mail.gmail.com>
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 <[email protected]> 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 (application/octet-stream, 381 B) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.