Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否有任何语法可以在 perl 中指示“后期静态绑定”?在php中,有。 http://php.net/manual/en/language.oop5.late-static-bindings.php
我只是在为 perl 寻找它们。
Perl 没有静态方法,所以你不需要技巧来使静态方法表现得像虚拟方法。
package ClassA { sub who { print __PACKAGE__, "\n" } sub test { my ($class) = @_; $class->who(); } } package ClassB { our @ISA = 'ClassA'; sub who { print __PACKAGE__, "\n" } } ClassA->test(); # ClassA ClassB->test(); # ClassB