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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                Extren可以用一個類型安全的方式來描述目標語言特定的交互。它們像普通類一樣定義,除了: > Externs can be used to describe target-speci?c interaction in a type-safe manner. They are de?ned like normal classes, except that * class關鍵字被extern 關鍵字領先, * 方法(第4.3節)沒有表達式, * 所有的參數和返回類型需要是顯式的。 > * the class keyword is preceded by the extern keyword, > * methods (4.3) have no expressions and > * all argument and return types are explicit. 常見的例子在Haxe標準庫(第10章),Math 類,摘錄如下: > A common example from the Haxe Standard Library (10) is the Math class, as an excerpt shows: ~~~ extern class Math { static var PI(default,null) : Float; static function floor(v:Float):Int; } ~~~ 我們看到,externs 既可以定義方法也可以定義變量(時尚,PI是聲明為一個只讀屬性(第4.2節))。一旦這個信息對于編譯器可用,它啟用相應的字段訪問,也被稱為類型: > We see that externs can de?ne both methods and variables (actually, PI is declared as a readonly property (4.2)). Once this information is available to the compiler, it allows ?eld access accordingly and also knows the types: ~~~ class Main { static public function main() { var pi = Math.floor(Math.PI); $type(pi); // Int } } ~~~ 這這可以運行,因為floor方法返回類型聲明為Int。 > This works because the return type of method floor is declared to be Int. Haxe標準庫帶有許多外部類,對于Flash和JavaScript目標語言。它們使可以以類型安全的方式訪問原生的APIs,當作設計高層APIs的工具。Externs也可以應用haxelib(第11章)中許多流行的原生庫。 > The Haxe Standard Library comes with many externs for the Flash and JavaScript target. They allow accessing the native APIs in a type-safe manner and are instrumental for designing higher-level APIs. There are also externs for many popular native libraries on haxelib (11). Flash,Java和C#目標語言允許通過命令行(第7章)直接包括原生的庫。目標特定的細節在每個目標語言細節(第12章)等各自的章節。 > The Flash, Java and C# targets allow direct inclusion of native libraries from command line (7). Target-speci?c details are explained in the respective sections of Target Details (Chapter 12). 一些目標語言如Python或者JavaScript可能需要產生附加的 import 代碼,為原生模塊加載一個extern 類。Haxe提供聲明這樣的依賴關系在各自的目標語言向細節(第12章)的方式。。 > Some targets such as Python or JavaScript may require generating additional ”import” code that loads an extern class from a native module. Haxe provides ways to declare such dependencies also described in respective sections Target Details (Chapter 12). **Haxe3.2.0以后剩余的參數和類型選擇** > Rest arguments and type choices Since Haxe 3.2.0 haxe.extern 包提供兩種類型幫助映射原生的語義到Haxe: > The haxe.extern package provides two types that help mapping native semantics to Haxe: **Rest<T>** 這個類型可以被實用為一個最終的函數參數,來使傳遞一個額外的調用參數任意的數值到函數。類型參數可以被使用來限制這些參數為某個特定類型。 > **Rest<T>**: This type can be used as a ?nal function argument to allow passing an arbitrary number of additional call arguments. The type parameter can be used to constrain these arguments to a speci?c type. **EitherType<T1, T2>**:這個類型允許使用任何一個類型參數類型,因此表示了一個類型選擇。它可以被嵌套來允許更多的類型。 > **EitherType<T1,T2>**: This type allows using either of its parameter types,thus representing a type choice. It can be nested to allow more than two different types. 我們在下面代碼示例中演示了其用法: > We demonstrate the usage in this code sample: ~~~ import haxe.extern.Rest; import haxe.extern.EitherType; extern class MyExtern { static function f1(s:String, r:Rest<Int>):Void; static function f2(e:EitherType<Int, String>):Void; } class Main { static function main() { MyExtern.f1("foo", 1, 2, 3); // use 1, 2, 3 as rest argument MyExtern.f1("foo"); // no rest argument //MyExtern.f1("foo", "bar"); // String should be Int MyExtern.f2("foo"); MyExtern.f2(12); //MyExtern.f2(true); // Bool should be EitherType<Int, String> } } ~~~
                  <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>

                              哎呀哎呀视频在线观看