小编ygu*_*mot的帖子

在 Raku 中,无法从同一文件中定义的类继承方法特征

用 trait_mod 定义的方法特征完美地继承自其他文件中定义的类。当这两个类在同一个文件中定义时,这似乎不起作用。

以下 2 个文件可以很好地协同工作:

# mmm.pm6

class TTT is export  {

    multi trait_mod:<is> (Routine $meth, :$something! ) is export
    {
        say "METH : ", $meth.name;
    }
}
Run Code Online (Sandbox Code Playgroud)
# aaa.p6

use lib <.>;
use mmm;

class BBB is TTT {
    method work is something {  }
}
Run Code Online (Sandbox Code Playgroud)

输出是: METH : work

但是在以下唯一文件中收集的相同代码给出了错误消息

# bbb.p6

class TTT is export  {

    multi trait_mod:<is> (Routine $meth, :$something! ) is export
    {
        say "METH : ", $meth.name;
    }
}

class BBB is TTT …
Run Code Online (Sandbox Code Playgroud)

raku

7
推荐指数
1
解决办法
109
查看次数

标签 统计

raku ×1