On Feb 25, 2009, at 3:39 PM, Dmitry Karasik wrote: > Hi Graham! > > On 25 фев 09 at 19:39, "Graham" (Graham Barr) wrote: > > Graham> For example, consider > > Graham> 1) use methods; would enable the use of the extra stash. > Without > Graham> it method lookup would happen as it does today. But if > specified > Graham> then perl would use a separate stash for method lookup. > > I think it's a reasonable idea. Originally I thought that the extra > stash > would be implemented so it is invisible from perl, but there's no > need for > that. If users of methods.pm would be aware that it uses > $ParentClass::__METHODS or something similar, then such technique > would > be both safe and backwards compatible. > > Graham> 2) Any sub declared with :method would automatically be placed > Graham> into the method stash > > I would extend this proposal so that all subs, even without :method, > but while "use methods" is in effect, would also be placed into the > method stash. This way upgrade costs would be minimal - noone would > rewrite the existing code by adding :method in all subs. I think that if an author want to protect themselves by adding use methods then having to add :method is not too much to ask. If you automatically put any sub defined in the package into the methods stash, then what has it bought you and how do you write private subs within a package that you do not want to appear as methods. > Graham> 3) For subs which are imported and used as methods, use > methods > Graham> could accept a list of sub names that should also be placed > into > Graham> the method stash. > > That, and if an exported sub was declared as :method itself, I think > solves the problem of deliberate mixins. Also, since exported names > have GvIMPORTED flag (that means can be easily distinguished from > native subs), a special syntax could be devised for adding > all imported subs into the method stash, without explicit enumeration. > For example "use methods 'mixin'"? I think "use methods ':mixin'" could do that. There is nothing to say that all subs imported come from packages that have tagged methods so you need the ability to specify that an imported sub is a method. Graham.Thread Previous | Thread Next