On 03/09/05, Yuval Kogman <[EMAIL PROTECTED]> wrote:
> A multi sub is a collection of variants, so it doesn't have arity,
> each variant has arity.
> 
> I'd say it 'fail's.

But if the reason you're calling `&foo.arity` is to answer the
question "Can I call this sub with three arguments?" then that kind of
behaviour isn't going to help very much.

Which leads me to believe that instead of writing

  if &foo.arity == 3 { ... }

you should probably be writing something like this:

  if &foo.accepts(3) { ... }

Implying that you could also write:

  if &foo.accepts(:pos(1..3) :named<foo bar> :code) { ... }

None of this really answers the question "What should &foo.arity
return?", but my point is that most of the time you probably shouldn't
be calling it yourself anyway.  Better to tell the sub what you
actually intend to do, and let it make up its own mind (via its
Signature(s)).

> To get the arity you must tell it which variant yyou mean, either by
> providing enough of the prototype, eg
> 
>         &foo(Any).arity   vs   foo(Any, Any).arity

Unfortunately, that particular syntax is going to end up *calling*
&foo (unless of course you make .arity a special form).


Stuart

Reply via email to