Sub call resolution

0 views
Skip to first unread message

Luke Palmer

unread,
May 30, 2005, 4:39:57 AM5/30/05
to perl6-l...@perl.org
Okay, I'd like to set myself straight. Sanity check:

bar($foo, $baz); # looks for subs (lexical then package), and
falls back to MMD
$foo.bar($baz); # looks in ref($foo), then falls back to MMD

If this is correct, can we simplify the latter to mean "MMD only" ?
Would there be a more symmetric MMD only form?

Luke

Larry Wall

unread,
May 31, 2005, 4:33:28 PM5/31/05
to perl6-l...@perl.org
On Mon, May 30, 2005 at 08:39:57AM +0000, Luke Palmer wrote:
: Okay, I'd like to set myself straight. Sanity check:

:
: bar($foo, $baz); # looks for subs (lexical then package), and
: falls back to MMD

Er, no.

: $foo.bar($baz); # looks in ref($foo), then falls back to MMD


:
: If this is correct, can we simplify the latter to mean "MMD only" ?
: Would there be a more symmetric MMD only form?

bar($foo, $baz) is the MMD form. However, MMD is defined to pay
attention to lexical scoping, and if the innermost definition of
the sub isn't multi, it reverts to ordinary sub dispatch. If the
innermost definition is multi, then all multies out to a scope
that is not multi are considered.

Basically, all sub calls are inherently MMD, but ordinary subs are
a degenerate wildcard case that hide any outer definitions.

Larry

Reply all
Reply to author
Forward
0 new messages