Perl 5 MOP - Internals - Dispatching
The next thing we need to discuss is how methods get dispatched. This is fundamental part of any object system and the primary thing which you do with the instances that are discussed in the previous document.
Note that we will allude to classes here, but we won't actually get into the details of them until the next document.
TODO - need to update this to reflect what we are currently doing in the prototype
I think it entirely possible that if we were to have proper anonymous stashes whose
mro can both understand a anonymous stash "object" as well as strings,
then it would be possible to compile,
upon class finalization,
a set of stashes which could be used for dispatching on the new style classes.
This would mean that the above described functions would not actually be executed at runtime, instead the existing built-in method dispatching mechanism would be used.
Not knowing the guts well enough, i am not sure which is really the saner option, to write a whole new dispatching mechanism based on the above described spec, or to somehow try and re-use the existing dispatching mechanism.
I have experimented somewhat with this using the prototype and the
Package::Anon experiment created by Florian Ragwitz but have not produced anything successful yet.
Some of the details of this are discussed here: http://www.nntp.perl.org/group/perl.perl5.porters/2011/09/msg177099.html
Package::Anon experiment is here: https://github.com/rafl/package-anon
This document contains a section entitled "The problem with Package based dispatching", which discussed my issues with package based dispatching (obviously). This should be viewed only as opinion and not as any guiding principle.
Stevan Little <firstname.lastname@example.org>
Copyright 2011 Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.