It doesn't. It just improves error messages.

words() produces a list-like thing; that's what really matters, because
list-like things do the Positional role. Declaring it up front lets Perl 6
give you an error message early if you use the result in the wrong way or
if the actual implementation of words() doesn't produce something that does
the Positional role.

pyanfar Z$ 6 'say (sub { [5] })()[0]'
5

I didn't declare the anonymous sub as producing a Positional; it just
returns a List. I then invoke it with (), and apply [] to the resulting
List. It's the fact that it produced a List that matters; any List or Seq
or Array or Buf, etc. can be []-ed,because they all do the Positional role
that defines [].


On Wed, Sep 26, 2018 at 9:51 PM ToddAndMargo <toddandma...@zoho.com> wrote:

> On 9/26/18 6:31 PM, ToddAndMargo wrote:
> > On 9/26/18 6:18 PM, Curt Tilmes wrote:>
> >  >      > The methods don't take [].  You are calling [] on the thing
> > that the
> >  >      > methods return.
> >
> >>>
> >>>     Yes, I know.  And it is human readable too.  It is one of the
> >>>     many reasons I adore Perl 6.
> >>>
> >>>     Where in
> >>>          multi method words(Str:D $input: $limit = Inf --> Positional)
> >>>     does it state that "words" will do that?  Not all methods will.
> >>>     So it need to be stated when they will.
> >>>
> >>>
> >
> >
> >
> >  > The part where it says "--> Positional" says the thing that gets
> >  > returned is Positional.
> >  >
> >  > A Positional thing has all sorts of methods and operators you can use,
> >  > including []
> >  >
> >  > Not all methods will, of course.  Only those that say "--> Positional"
> >  > return a Positional that acts like that.
> >  >
> >  > Curt
> >
> > Hi Curt,
> >
> > Perfect! Thank you!
> >
> > So all methods that respond with --> Positional will accept []
> >
> > Awesome!
> >
> > -T
>
>
>
> I do believe the reason I spaced on this was that when I see "-->"
> what goes through my head is "this is the value(s) returned".
> I had not idea it would reflect backwards and affect the method.
>
> There should be a better way of stating this.
>


-- 
brandon s allbery kf8nh
allber...@gmail.com

Reply via email to