dakkar wrote:

Say I have:

multi sub foo(Array $a,Int $b) {...}
multi sub foo(Hash %a, Int $b) {...}

and I want to (distinctly) wrap each multisub, say for testing, or AOP,
or whatever. How do I get the two different code references? As far as i
can gather from the Apocalipses and Synopses, there should be a way to
express the "long name", and use that to get the ref. Is there any
proposed syntax for this? (I ask about syntax because the semantic seems
pretty clear...)


It used to be


but I seem to recall that there was a mild change that occurred. Or maybe I'm thinking about the adding of the colon for operators. I'm not certain, but it's something very close to the above.

In my mind, the more interesting question is what does &foo without the <> specifiers return when foo is multi? I see the following three options:

1) undef/error, since there's no single sub called foo, and multi's need a postfix <>.

2) the name 'foo', and then performs in effect call by name when deferenced, using the dereferencing scope to determine which flavors of foo are available at this time, and dispatching accordingly.

3) a dispatch table of all the foo's currently in scope at the time the reference is made.

Personally, I think #3 would be the most useful.

-- Rod Adams

Reply via email to