That's a great response, thanks. Clears things up. One question, should be
always be using _ for the invocant or should we try to restrict it?

On Wed, Sep 17, 2008 at 10:52 PM, Patrick R. Michaud <[EMAIL PROTECTED]>wrote:

> On Wed, Sep 17, 2008 at 08:37:36PM +0800, Chris Davaz wrote:
> > I am confused about how we should setup method signatures:
> >
> > Let's take a look at a line in any-str.pir:
> >
> >  46 .sub 'comb' :method :multi(_)
> >  47     .param pmc regex
> >  48     .param int count        :optional
> >  49     .param int has_count    :opt_flag
> >
> > As you can see we have one parameter specified in :multi which is _ (any
> > type). However we also have two .param lines, 47 and 48. So here are some
> > questions:
> >
> > I noticed 'self' is implicitly defined, however does 'self' eat up a
> > parameter? Should we always have one parameter in :multi specified for
> the
> > object the method is running on?
>
> Yes, the first argument of the :multi refers to the invocant.
>
> > Also, I played around with :multi by putting in different things. With
> the
> > above method here is what I tried and the result
> >
> > :multi(_) - works
>
> Restricts the sub to being invoked by callers supplying
> at least one argument (in this case, the argument is the
> invocant, since the sub is declared as :method).
>
> > :multi(_, _) works
>
> This says that the sub requires at least two arguments (of any
> type).  The first will go into 'self', the second into 'regex'.
>
> > :multi(_,_,_) doesn't work
>
> This says that the sub requires at least three arguments (of
> any type).  This doesn't really match the sub definition though,
> which has an invocant, a required argument, and an optional argument.
>
> > :multi(_,Integer) doesn't work
>
> This says the invocant may be of any type, and the first argument
> must be an Integer (or a subclass of Integer).  Probably not what
> we want given that the first parameter of the sub is 'regex'.
>
>
> > :mult(Sub) doesn't work
>
> This says that the sub can be invoked only on Sub invocants.
>
> > Some clarification surrounding the use of :multi would help a lot.
>
> Hope the above helps.  I don't know where :multi is documented in
> Parrot itself; the pdd27 file doesn't provide much detail.
>
> Pm
>

Reply via email to