porting - "Illegally post-declared types"带循环类定义

标签 porting raku

乐堂版本 2020.01

这不编译。

use v6;

class N1 {}
class T1 {}

class G1 {
    has @.g is required where A1|Q1;
}

class Q1 {
    has $.q is required where N1|T1|G1;
}

class A1 {
    has Q1 @.a is required;
}
===SORRY!=== Error while compiling …
Illegally post-declared types:
    A1 used at line 7
    Q1 used at line 7

我认为仅在 G1 之前声明标识符会帮助我,但这也失败了:
===SORRY!=== Error while compiling …
Too late for unit-scoped class definition;
Please use the block form.
…:6
------> class A1;⏏ class Q1;

我如何使它工作?

最佳答案

您可以,但您需要将类定义为 stub 。

class A { }

只会定义一个空类。然而:
class A { ... }   # note the yadayadayada

将定义一个 stub 。所以补充:
class A1 { ... }
class Q1 { ... }

到您的代码顶部,应该可以解决问题。

关于porting - "Illegally post-declared types"带循环类定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60041718/

相关文章:

Python 等效于 MATLAB 命令 prod

java - 哪个编译器用于通过 ndk 移植 C++?

cocoa - Delphi 有哪些好的 Cocoa API 端口

raku - 如何从 block 的CATCH相位器返回值?

raku - 有没有类似于Python中的Counter的内置方法?

raku - 在 NativeCall perl6 模块中声明指针 [void] 的奇怪消息

raku - BEGIN 何时真正启动(或运行)?

c++ - 将 win32 代码 (windows.h) 移植到 linux

c++ - 将 C++ 游戏移植到 Objective-C

grammar - 命名语法规则的元对象规则是什么