多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
一个模块子类型是在一个模块中声明,但是不同于模块名的类型。这允许一个单独的 .hx 文件包含多个类型,可以在模块内无限制的使用,而从其它模块中使用 package.Module.Type 访问: > A module sub-type is a type declared in a module with a different name than that module. This allows a single .hx file to contain multiple types, which can be accessed unqualified from within the module, and by using package.Module.Type from other modules: ~~~ var e:haxe.macro.Expr.ExprDef; ~~~ 这里haxe.macro.Expr内部的子类型ExprDef被访问。 > Here the sub-type ExprDef within module haxe.macro.Expr is accessed. 子类型关系并不在运行时反映。即,公共子类型称为一个它们的包含包的成员,如果相同包内的两个模块尝试定义相同的子类型时可能会造成冲突。自然,Haxe编译器侦测这些情况并做出相应报告。在上面的例子中 ExprDef 是生成为 haxe.macro.ExprDef。 > The sub-type relation is not reflected at run-time. That is,public sub-types become a member of their containing package, which could lead to conflicts if two modules within the same package tried to define the same sub-type. Naturally, the Haxe compiler detects these cases and reports them accordingly. In the example above ExprDef is generated as haxe.macro.ExprDef. 子类型也可以声明为私有: > Sub-types can also be made private: ~~~ private class C { ... } private enum E { ... } private typedef T { ... } private abstract A { ... } ~~~ **私有类型** >[warning] 定义:私有类型 一个类型被定义为私有,通过 private 修饰符。其结果,这个类型只能从定义它的这个模块内部直接访问。私有类型,不像公共类型,不会称为它们包含包的成员。 >[warning] Definition: Private type A type can be made private by using the private modifier. As a result,the type can only be directly accessed from within the module (3.7) it is defined in. Private types, unlike public ones, do not become a member of their containing package. 类型的可访问性可以通过使用访问控制(第6.10节)进行更深入的控制。 > The accessibility of types can be controlled more fine-grained by using access control (6.10).