5
這是來自我以前的Why is Perl 6's unwrap method a method of Routine?的一個持續問題,但大多數情況下並不相關。爲什麼我不能在Routine :: WrapHandle上調用元方法?
的wrap
方法記錄在案,以返回「之稱WrapHandle一個私有的類的實例,除此之外爲奇數對泄漏一類是私有的,它不是真正的那個回來的東西的名字的類實際上是Routine::WrapHandle
。: 。
$ perl6
> sub f() { say 'f was called' }
sub f() { #`(Sub|140397740886648) ... }
> my $wrap-handle = &f.wrap({ say 'before'; callsame; say 'after' });
Routine::WrapHandle.new
但這裏的問題,我想叫.^methods
上Routine::WrapHandle
這並不工作:
> Routine::WrapHandle.^methods
Could not find symbol '&WrapHandle'
in block <unit> at <unknown file> line 1
這是一樣的嘗試它在一個未定義的C ^姑娘的名字:
> Foo::Baz.^methods
Could not find symbol '&Baz'
in block <unit> at <unknown file> line 1
我可以調用雖然實例元方法:
> $wrap-handle.^methods
(restore)
> $wrap-handle.^name
Routine::WrapHandle
這是怎麼回事呢?
這是[詞彙班級](https://github.com/rakudo/rakudo/search?&q=WrapHandle&type=) –