On Tue, Jun 02, 2020 at 08:52:37AM +0300, Peter Pentchev wrote:
> On Mon, Jun 01, 2020 at 01:36:19PM -0700, ToddAndMargo via perl6-users wrote:
[snip]
> > A follow up question:
> > 
> > Is there a booboo in the documentation here?
> > 
> > https://docs.raku.org/routine/starts-with
> > multi method starts-with(Str:D: Str(Cool) $needle, :i(:$ignorecase),
> > :m(:$ignoremark) --> Bool:D)
> > 
> > It says "multi method" but only shows one method.
> > Did they leave something out?
> 
> Mmm, and this is where we come to the original error message :)
> It says that there is a "starts-with()" method in the Str class that
> accepts a "$needle" parameter of the Str:D type, but then (or, rather,
> before that) it says that there is a "starts-with()" method in the Cool
> class that accepts a "$neddle" parameter of the Cool:D type. Since Str
> is derived from Cool, when you call a method on Str Raku will also look
> for this method in Cool. Since the two methods accept parameters of
> different types, they (or at least the method in the child class Str)
> have to be declared as multi methods so Raku knows that a type mismatch
> on the first one that it found does not mean that it should stop
> looking.
> 
> But, hm, why the documentation of the starts-with() method on the page
> that you linked to does not mention that it is also present in Cool is
> indeed an interesting question. Moreover, even the list of methods at
> https://docs.raku.org/routine-method.html says "method starts-with()
> from Str", while other methods such as subst() are listed as "from Cool,
> Str", etc. I honestly don't know what the difference is, I expect it is
> because of some internal details of the implementation of the Str
> method, but I won't be able to look it in the source right now. Maybe
> somebody else could shed some light on that?

OK, so I have a theory. Is it possible that this is because
Str.starts-with() has a coercion of its $needle parameter from Cool, so
whatever is building the documentation deduces (correctly) that
Cool.starts-with() will never be invoked on anything that is Str or is
derived from Str? Still, should the documentation not, well, document
that any class derived from Cool has a starts-with() method?

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to