Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

sub and method name overlap.

5 views
Skip to first unread message

Rod Adams

unread,
Mar 10, 2005, 4:27:23 PM3/10/05
to Perl6 Language List
Given:

class Foo {
method Bar () {...};
}

sub Bar (Any $x) {...};
my Foo $f;

Bar $f;


Is that last line the same as:
&Bar.($f);
or
$f.Bar;

Does it matter if we change C< sub Bar > to C< multi sub Bar >?

Is there some form of implicit multi sub that gets created to make C<
Bar $f; > C< $f.Bar >? Or does it only work if there is no C< multi? sub
bar > in sight?

-- Rod Adams

Jonathan Scott Duff

unread,
Mar 10, 2005, 10:02:37 PM3/10/05
to Rod Adams, Perl6 Language List
On Thu, Mar 10, 2005 at 03:27:23PM -0600, Rod Adams wrote:
> Given:
>
> class Foo {
> method Bar () {...};
> }
>
> sub Bar (Any $x) {...};
> my Foo $f;
>
> Bar $f;
>
>
> Is that last line the same as:
> &Bar.($f);
> or
> $f.Bar;

I don't see how it can be anything but the former. As I understand
things, when searching for a matching sub/method, the subs are
given preference over indirect objects.

> Does it matter if we change C< sub Bar > to C< multi sub Bar >?

Nope.

> Is there some form of implicit multi sub that gets created to make C<
> Bar $f; > C< $f.Bar >?

I don't think so.

> Or does it only work if there is no C< multi? sub bar > in sight?

That's how I see (no sub or multi in sight)

You can always be explicit if you really want to use the IO notation:

Bar $f:;

-Scott
--
Jonathan Scott Duff
du...@pobox.com

0 new messages