On Dec 25, 2007 4:37 PM, Allison Randal <[EMAIL PROTECTED]> wrote: > Klaas-Jan Stol wrote: > > I guess you're right :-) I was thinking of ambiguity, like > > > > sub foo :multi(Integer, Integer) > > .param pmc i :invocant > > .param pmc j > > .param pmc k :invocant > > end > > > > sub foo :multi (Integer, Integer) > > .param pmc j :invocant > > .param pmc k :invocant > > end > > > > but I guess parrot will see that the other foo has 2 parameters while > the > > first has 3, and make the selection based on that > > Like :optional, the :invocant parameters must all be contiguous. So, > only the second of those is valid, though you can have as many > non-:invocant parameters as you like after the last :invocant parameter. > Also, :invocant parameters can't be :optional.
Earlier I read over this, thinking: there's probably a good reason for that (the need for being contiguous), but I haven't figured it out yet. For sake of documentation, could you please explain why this is so? so, why would it not be possible to write this: .sub foo :multi .param pmc x :invocant('Integer') .param pmc y .param pmc z :invocant('Integer') ... and .sub foo :multi .param pmc x :invocant('Integer') .param pmc y .param pmc z :invocant('String') The former "foo" can be thought of as having signature "Integer, *, Integer" and the second "Integer, *, String", (where * means any type, don't care). I don't see a particular problem. Not that I need to be able to do this, just wondering why this rule is so. thanks, kjs > > > > BTW, :invocant looks a bit like ".invcant", which is also a directive. > Can > > that confuse people? > > Do you mean ".invocant"? They are related concepts, as .invocant sets > the single invocant of a method call, while :invocant tells a > multisub/method to treat a set of parameters as invocants. Any .sub > marked with :method and :multi always treats the method invocant as if > it was marked with :invocant, even though it isn't retrieved with .param. > > We might want to consider adding a standard prefix to .invocant, as well > as to .arg, .result, etc, to make it clear that they're a group of > directives all combined to make a single PCC call. > > Allison >