<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                通常,Haxe編譯器只生成一個單獨的類或者函數,即使它有類型參數。生成的代碼之后可能必須執行一些類型檢查可能會影響一些性能。這發生在一個自然抽象概念中,目標語言的代碼生成器必須假設一個類型參數可以是任何類型。 > Usually, the Haxe Compiler generates only a single class or function even if it has type parameters. This results in a natural abstraction where the code generator for the target language has to assume that a type parameter could be of any type. The generated code then might have to perform some type checks which can be detrimental to performance. 一個類或者函數可以通過使用 :generic 元數據(第6.9節)歸類為泛型。這導致編譯器每個類型參數和破損的名字的混合,發射一個不同的類/函數。一個這樣的規范可以產生一個性能關鍵代碼的減少分配到靜態目標語言(第2.2節)的生成文件大小: > A class or function can be made generic by attributing it with the :generic metadata (6.9). This causes the compiler to emit a distinct class/function per type parameter combination with mangled names. A speci?cation like this can yield a boost in performance-critical code portions on static targets (2.2) at the cost of a larger output size: ~~~ @:generic class MyValue<T> { public var value:T; public function new(value:T) { this.value = value; } } class Main { static public function main() { var a = new MyValue<String>("Hello"); var b = new MyValue<Int>(42); } } ~~~ 似乎不常見這里的顯式類型 MyValue<String>,因為我們通常讓類型推斷(第3.6節)處理它。盡管如此,它確實需要在這種情況下被需要。編譯器必須了解泛型類的準確類型一經構建。JavaScript輸出顯示結果: > It seems unusual to see the explicit type MyValue<String> here as we usually let type inference (3.6) deal with this. Nonetheless, it is indeed required in this case. The compiler has to know the exact type of a generic class upon construction. The JavaScript output shows the result: ~~~ (function () { "use strict"; var Test = function() { }; Test.main = function() { var a = new MyValue_String("Hello"); var b = new MyValue_Int(5); }; var MyValue_Int = function(value) { this.value = value; }; var MyValue_String = function(value) { this.value = value; }; Test.main(); })(); ~~~ 我們可以確定 MyValue<String>和MyVlue<Int> 已經變成 MyValue_String 和MyValue_Int 。這類似于泛型函數: > We can identify that MyValue<String> and MyValue<Int> have become MyValue_String and MyValue_Int respectively. This is similar for generic functions: ~~~ class Main { static public function main() { method("foo"); method(1); } @:generic static function method<T>(t:T) { } } ~~~ 再一次,JavaScript輸出使其非常明顯: > Again, the JavaScript output makes it obvious: ~~~ (function () { "use strict"; var Main = function() { } Main.method_Int = function(t) { } Main.method_String = function(t) { } Main.main = function() { Main.method_String("foo"); Main.method_Int(1); } Main.main(); })(); ~~~
                  <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>

                              哎呀哎呀视频在线观看