<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                如果一個類型路徑在一個 .hx 文件中會多次用到,可以使用 import 導入來縮短它。這可以使我們省略包名來使用類型: > If a type path is used multiple times in a .hx ?le,it might make sense to use an import to shorten it. This allows omitting the package when using the type: ~~~ import haxe.ds.StringMap; class Main { static public function main() { // instead of: new haxe.ds.StringMap(); new StringMap(); } } ~~~ 第一行haxe.ds.StringMap被導入之后,編譯器可以在main函數中解析絕對的標識符 StringMap到它的包中。 > With haxe.ds.StringMap being imported in the ?rst line,the compiler is able to resolve the unquali?ed identi?er StringMap in the main function to this package. The module StringMap is said to be imported into the current ?le. 在這個例子中,我們實際上導入了一個模塊,而不只是模塊中的一個類型。這意味著所有在導入的模塊中定義的類型都是可用的。 > In this example, we are actually importing a module, not just a speci?c type within that module. This means that all types de?ned within the imported module are available: ~~~ import haxe.macro.Expr; class Main { static public function main() { var e:Binop = OpAdd; } } ~~~ 類型 Binop 是haxe.macro.Expr模塊中一個 enum(第2.4節)聲明,因此被提到的包導入之后就可用了。如果我們只要導入模塊中的一個特定類型,例如,import haxe.macro.Expr.ExprDef,程序會編譯失敗,提示Binop類沒有找到。 > The type Binop is an enum (2.4) declared in the module haxe.macro.Expr,and thus available after the import of said module. If we were to import only a speci?c type of that module, e.g. import haxe.macro.Expr.ExprDef, the program would fail to compile with Class not found : Binop. 關于導入有幾個方面需要了解: > There are several aspects worth knowing about importing: * 最下面的導入有最高的優先級(詳見 解析順序(第3.7.3節))。 * 靜態擴展(第6.3節)關鍵字 using 意味著 import 的效果。 * 如果一個enum被導入(直接或者作為模塊的一部分導入),所有它的enum構造函數(第2.4.1節)同樣也被導入(這就是在上面例子中允許 opAdd 的用法)。 > * The bottommost import takes priority (detailed in Resolution Order (Section 3.7.3)). > * The static extension (6.3) keyword using implies the effect of import. > * If an enum is imported (directly or as part of a module import), all its enum constructors (2.4.1) are also imported (this is what allows the OpAdd usage in the above example). 此外,也可以導入類的靜態字段并不受限制的使用它們。 > Furthermore, it is also possible to import static ?elds (4) of a class and use them unquali?ed: ~~~ import Math.random; class Main { static public function main() { random(); } } ~~~ 必須特別注意,字段名或者局部變量名和包名的沖突:因為它們優先級高于包,一個局部變量名為haxe,會阻擋整個haxe包的使用。 > Special care has to be taken with ?eld names or local variable names that con?ict with a package name: Since they take priority over packages, a local variable named haxe blocks off usage the entire haxe package. **通配符導入**:Haxe允許使用 .* 使 import可以導入一個包中所有的模塊,模塊中的所有類型或者類型中的所有靜態字段。理解這種導入只通過一個在下面例子中的單獨級別: > **Wildcard import** Haxe allows using .* to allow import of all modules in a package, all types in a module or all static ?elds in a type. It is important to understand that this kind of import only crosses a single level as we can see in the following example: ~~~ import haxe.macro.*; class Main { static function main() { var expr:Expr = null; //var expr:ExprDef = null; // Class not found : ExprDef } } ~~~ 使用通配符到haxe.macro的導入,使這個包中的 Expr模塊可以被訪問,但是它不能使Expr模塊的子類型ExprDef被訪問。這個規則當一個模塊被導入時也擴展到靜態字段。 > Using the wildcard import on haxe.macro allows accessing Expr whichisa module in this package, but it does not allow accessing ExprDef which is a sub-type of the Expr module. This rule extends to static ?elds when a module is imported. 當使用通配符導入一個包,編譯器并不急于處理包中的所有模塊。這意味著這些模塊除非被明確使用否則不會實際的被編譯器發現,也不會出更為生成的輸出的一部分。 > When using wildcard imports on a package the compiler does not eagerly process all modules in that package. This means that these modules are never actually seen by the compiler unless used explicitly and are then not part of the generated output. **使用別名導入** 如果一個類型或靜態字段在一個導入它的模塊中經常使用,可以為它引入別名為一個簡短的名字。這也可以用來通過給定一個唯一的標識符來消除命名沖突。 > **Import with alias** If a type or static ?eld is used a lot in an importing module it might help to alias it to a shorter name. This can also be used to disambiguate con?icting names by giving them a unique identi?er. ~~~ import String.fromCharCode in f; class Main { static function main() { var c1 = f(65); var c2 = f(66); trace(c1 + c2); // AB } } ~~~ 這里我們導入String.fromCharCode為 f,使我們可以使用 f(65) 和 f(66)。達到和局部變量一樣的使用,這個方法是編譯時功能,不會有運行時開銷。 > Here we import String.fromCharCode as f which allows us to use f(65) and f(66). While the same could be achieved with a local variable, this method is compile-time exclusive and guaranteed to have no run-time overhead. **從Haxe3.2.0后 ,Haxe允許使用更自然的 as 替代 in **。 > **Since Haxe 3.2.0** Haxe also allows the more natural as in place of in.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看