How to inject methods

chromatic chromatic at
Mon Jun 28 18:19:18 UTC 2010

On Monday 28 June 2010 at 10:52, Andrew Whitworth wrote:

> Is the issue that it's absolutely terrible design to have the methods
> available from the namespace in any way, or that methods shouldn't get
> mixed in with other types of objects that the namespace stores?


1) You have a NameSpace PMC.  You look up a symbol in that PMC.  You get back 
something you can invoke: something that isa or does Sub.  Is it a method?

2) You have a NameSpace PMC connected to a class.  You add a Sub to that PMC.  
The name you use happens to collide with the name of a method in a parent 
class.  Which Sub PMC should you call for method dispatch?

3) You want a list of all methods in a NameSpace.  How do you avoid false 
positives and false negatives?

Perl 5 borrowed Python's idea of commingling functions and methods, especially 
with regard to their storage and lookup.  You cannot solve these problems in 
Perl 5 without adding a metaprogramming layer (such as Moose) and enforcing 
its use *everywhere* in your program.  Woe be to you if you use CPAN modules.

-- c

More information about the parrot-dev mailing list