On Sun, Oct 26, 2008 at 09:37:36PM -0400, Bob Rogers wrote: > .sub 'main' :main > foo('Hello') > .end > .sub foo :multi(String) > .param pmc s > > say s > .end > [...] > Which brings us to an interesting question: How can you decide what > type to use for autoboxing before you've determined the actual sub > you're going to call? And how can you find the sub without having the > correct dispatch types up front?
According to t/pmc/multidispatch.t, :multi can specify 'string', 'int', and 'num' to match the native (non-PMC) types: .sub p :multi(string) .param string s print s .end .sub p :multi(string, string) .param string opt .param string s if opt != '-twice' goto no_twice print s print s .return() no_twice: print s .end Based on this, I would expect foo('hello') to dispatch to a sub via :multi(string) and not dispatch to :multi(String). As far as I can tell, this hasn't been deprecated anywhere, and is explicitly recognized in pdd27 (line 43): =item - Dispatch considers both low-level (register) types and high-level (PMC) types, as well as inherited and composed types. Returning to chromatic's original post, "no applicable methods" is actually what I would expect from the code given, since there are no methods defined taking the 'string' or 'int' type as the first argument. If there's a version that does work using String and Integer :multi's, then perhaps that's the one with the bug. It's also possible that I'm completely misinterpreting the :multi semantics, but that's the way things have tended to work up to now, and I haven't seen any documentation or messages that contradict it. Pm