On Dec 29, 2007 11:34 AM, Allison Randal <[EMAIL PROTECTED]> wrote: > Klaas-Jan Stol wrote: > > > > 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. > > From both a parsing and self-documentation perspective, it's clearer to > explicitly say: > > .sub foo :multi > .param pmc x :invocant('Integer') > .param pmc y :invocant('ANY') > .param pmc z :invocant('String') > .param pmc a > > than it is to simply leave 'y' blank. > > The behavior of the parameters 'y' and 'a' are a bit different. The 'a' > parameter is only considered at the very start to knock out signatures > that couldn't possibly fit (wrong number of required parameters). The > 'y' parameter is a full participant in multi-dispatch, and contributes > to the overall score of the signature for a particular call. An > "Integer, Integer, Integer" signature may be considered a better match > for a call than "Integer, *, Integer" (when the call is all Integers), > because it's more specific to the particular types passed. >
I think the penny dropped here :-) I'll write down here how I see it, also so that I don't forget, and this text can be rephrased into documentation. Assume that :invocant markers do not need to be contiguous, then: Essentially, you don't know how many :invocants there are for a specific :multi. For instance: .sub foo :multi .param pmc a :invocant('Integer') .param pmc b .param pmc c .. .end Is this sub a multi that takes 1 invocant (of type Integer) or maybe an Integer parameter and 1 'any' parameter (don't care which type), or maybe 2 don't-care types. In order to solve that, adding a :invocant('any') (* a special marker would be more convenient, maybe someone would like to define a class 'any' (you never know :-) but that's beside the pointnow *) By adding these markers, what effectively happens is that all :invocant parameters that are considered the :multi signature, are grouped together, anyway. So, this is the reason that :invocant-marked params must be grouped together. kjs