David Storrs wrote:

On Wed, Mar 09, 2005 at 03:38:52PM -0600, Rod Adams wrote:



There lingers the case of:
use Foo; # from above, exports &bar is MMD::Random


  multi sub bar {...}

Does this generate an error, since one could expect this particular &bar to be Manhattan? Or does it assume Random, since there's already a &bar in existence? In my head, it currently makes sense to say that the new &bar inherits the Random policy. Only something like:



This seems like action-at-a-distance to me; I use some random module,
define a couple of multis without realizing that they also exist in
the module, and am baffled as to why I don't get the dispatch behavior
I expect.


Well, if you were not expecting Foo to export some &bar's, then you're in for a surprise regardless of dispatch when you call &bar in your code and one of Foo::bar gets called instead of one of yours, because it was a closer match.

I would say that people should know what they are getting into when they C< use > something. In Perl 6, that use could "conviently" swap the meanings of all the + and - signs, and not say a word. In my head, this extends to knowing what it exports, and if there's anything weird about it.

If I am consciously adding more multi's into something a package provided, to extend it's functionality, I would think that keeping the original dispatch system would make sense. Otherwise the imported methods could fail to work properly.

-- Rod Adams




Reply via email to