Multiple Dispatch Tasklist

PIR:

* Declaring a :multi sub in PIR needs to respect HLL type mapping for a custom multiple sub type.

src/pmc/multisub.pmc:

* Add a sub lookup to the standard interface for MultiSub (grab an array of variants, sorted by likelyhood).

* Add "find next method" to MultiSub interface.

src/inter_call.c:

* Refactor the common code between 'Parrot_PCCINVOKE' and 'Parrot_pcc_invoke_sub_from_sig_object' into a set of functions.

src/mmd.c:

* 'mmd_expand_x' and 'mmd_expand_y' go away, MMD variants are just stored in the namespace.

* 'mmd_add_by_class' goes away, mmds are always added by class name, because they're added to the namespace.

* 'mmd_create_builtin_multi_meth' changes to 'Parrot_mmd_add_global'.
* 'mmd_create_builtin_multi_stub' changes to 'Parrot_mmd_add_global' with a null argument for 'entry', or just deprecated (stub is added when first mmd alternate is stored, no need for it before).

* Deprecate 'Parrot_mmd_register_table' and 'Parrot_mmd_rebuild_table'.

* Handle inheritance and best-match searching in multiple dispatch (see RT #45943).

* Deprecate 'mmd_register' and 'mmd_register_sub' (multis are stored in the namespace).

* Deprecate 'mmd_destroy' (multis are stored in the namespace).

* Deprecate or refactor/rename: 'mmd_arg_tuple_func', 'mmd_search_default', 'mmd_search_classes', 'distance_cmp', 'mmd_cvt_to_types', 'mmd_sort_candidates', 'mmd_search_scopes', 'mmd_is_hidden', 'mmd_maybe_candidate' functions.

* Deprecate 'mmd_get_ns' and 'mmd_make_ns' functions

include/parrot/mmd.h:

* Deprecate '_MMD_init' and '_MMD_table' structures.

src/ops/math.ops:

* Deprecate 'infix' and 'n_infix' opcodes.

For after the merge:

* Maybe change the name of NCI PMC to CFunction PMC (or just implement it fresh).
* Should MultiSub inherit from Sub and contain a data structure for each variant, instead of inheriting from ResizablePMCArray. Some information, like the signature of the variant, can be extracted once and cached, instead of extracted repeatedly.
* Deprecate all 'n_*' variants of opcodes (see RT #58410).
* Deprecate all 'i_*' vtable functions.

Completed:

* Create pdd27mmd branch. (allison, r30235)
* 'mmdvtregister' and 'mmdvtfind' are deprecated in trunk. (allison, r30263)
* src/mmd.c is replaced by src/multidispatch.c. (smash, r30259)
* Function names (for public interface) change to Parrot_mmd_X instead of mmd_X. (smash, r30259) # bug me if i skipped any
* Change name of file include/parrot/mmd.h to include/parrot/multidispatch.h. (smash, r30259)
* 'Parrot_mmd_sort_candidate_list' changed to 'Parrot_mmd_sort_manhattan'. (whiteknight, r30349, from patch RT #58088)
* Deprecate 'mmd_create_builtin_multi_meth_2'. (whiteknight, r30352, from patch RT #58090)
* Replace 'mmdvtregister' and 'mmdvtfind' opcodes with 'add_multi' and 'find_multi' in pdd27mmd branch. (smash, r30358)
* Parse a MULTI declaration similar to METHOD in PMCs. (allison, r30391)
* 'mmd_search_cur_namespace' changes to 'Parrot_mmd_search_local'. (smash, r30403)
* 'mmd_search_builtin' changes to 'Parrot_mmd_search_global'. (smash, r30403)
* Store MULTI declared subs as a MultiSub in the namespace vtable overrides, can have multiple variants with the same name declared in the same PMC. (allison, r30446)
* Change all MMD_* blocks in PMC files to MULTI declarations. (smash, r30506 and r30581)
* Add opcodes for the PMC versions of 'add', 'sub', 'mul', 'div', 'fdiv', 'mod', 'cmod', 'pow', 'bor', 'band', 'bxor', 'bors', 'bands', 'bxors', 'shl', 'shr', 'lsr', 'concat', 'repeat', 'or', 'and', 'xor'. (allison, various commits)

* One mmd_dispatch function (for calls from C) that either sets up a standard signature in the interpreter or passes varargs. (Having a dozen MMD dispatch functions with different static signatures is unmaintainable. If they exist, they should just make one call passing in a string signature.) (allison, various commits)
* Add a MultiOp PMC that does multiple dispatch on C function pointers, or just add NCI PMCs to MultiSub. (allison, various commits)
* 'mmd_vtfind' goes away, replaced by 'Parrot_mmd_find_multi_from_long_sig'. (allison, various commits, mmd_vtfind removed in r31061)
* Update the 'dump_multi' routine in examples/namespace/namespace_dump.pir to match the new MMD implementation. (allison, r30964)
* In compilers/imcc/parser_util.c deprecate 'is_infix' and 'to_infix' functions and remove calls to them from 'INS' function. (allison, r31067)

Questions:

* recent checkins show MULTI replacing instead of modifying the VTABLE keyword in PMC definitions: How will MULTI METHODs be declared? (I would argue that we keep VTABLE in the declaration, even if it is a little more verbose. -Coke) (Strictly speaking, multis aren't vtable functions or methods, because they dispatch on multiple invocants -Allison) (Anything declared with MULTI in C is stored as both a sub and a method and a global multi, so there is no distinction. -Allison)