At 8:07 AM +0200 8/4/04, Leopold Toetsch wrote:
Chromatic [EMAIL PROTECTED] wrote:
Hi all,
I'd like to register some subroutines defined in PASM (or better, PIR)
as participating in multiple dispatch. This is very handy when writing
Test::Builder::is(), for example, which can compare two strings,
integers, numbers, or PMCs, or for calling NCI functions which can take
various types and numbers of arguments that all do very similar things.
Dan suggested a new op with a scheme similar to:
register_mmd S1, S2, P
- MMD is misleading. MMD is our function dispatching scheme for
binary-like vtables.
MMD's more generic than that. We've only got it implemented for
binary vtables, but that doesn't mean it's only used for them.
I'd call it
register_multi Smulti, Sreal, Sproto
register_multi Pmulti, Preal, Sproto
CSproto is a runops prototype specifier like III for add_integers.
An array is a bit to heavy for that IMHO.
Sproto would be really too restrictive. For subs we need to be
checking the types of the PMC parameters. Encoding that in a string's
just too much flattening and unflattening.
Besides, these things'll be executed exactly once, so we might as
well make them convenient.
There are other options for declaring the signature. There could be:
register_mmd S1, S2, I1, I2, I3, P
where I1 is the number of arguments in the I register,
Register counts don't say anything about argument order. I don't think
that'll work.
Argument order's irrelevant for different register types, so it
doesn't much matter. This could be an issue, but I don't think we'll
see one here.
--
Dan
--it's like this---
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk