<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之旅 廣告
                如果基礎的可見性(第4.4.1節)選項不滿足需求,可以使用訪問控制。它適用于類級別和字段級別,知道兩個方向: > Access control can be used if the basic visibility (4.4.1) options are not suf?cient. It is applicable at class-level and at ?eld-level and knows two directions: 允許訪問:目標是一個授予的訪問指定類或者字段,使用 :allow(target) 元數據(第6.9節)。 禁止訪問:目標是一個禁止訪問的指定類或字段,使用 :access(target) 元數據(第6.9節)。 > **Allowing access**: The target is granted access to the given class or ?eld by using the :allow(target) metadata (6.9). > **Forcing access**: A target is forced to allow access to the given class or ?eld by using the :access(target) metadata (6.9). 在這個上下文中,一個目標可以是一個點路徑(第3.7節)到: * 一個類字段 * 一個類或者抽象類型 * 一個包 > In this context, a target can be the dot-path (3.7) to > * a class ?eld, > * a class or abstract type, or > * a package. 目標不能遵從導入,所以必須是完整的合格路徑。 > Target does not respect imports, so the fully quali?ed path has to be used. 如果它是一個類或者抽象類型,訪問修正延伸到所有這個類型的字段。同樣的,如果它是一個包,訪問修正延伸到所有這個包的類型和遞歸到所有這些類型的字段。 > If it is a class or abstract type, access modi?cation extends to all ?elds of that type. Likewise, if it is a package, access modi?cation extends to all types of that package and recursively to all ?elds of these types. ~~~ @:allow(Main) class MyClass { static private var foo: Int; } class Main { static public function main() { MyClass.foo; } } ~~~ 這里 ,MyClass.foo 可以從main方法中訪問,因為 MyClass 被使用 @:allow(Main) 注釋。這也可以使用 @:allow(Main.main),這兩種方法都可以作為字段foo的注釋替代對MyClass的注釋: > Here, MyClass.foo can be accessed from the main-method because MyClass is annotated with @:allow(Main). This would also work with @:allow(Main.main) and both versions could alternatively be annotated to the ?eld foo instead of the class MyClass: ~~~ class MyClass { @:allow(Main.main) static private var foo: Int; } class Main { static public function main() { MyClass.foo; } } ~~~ 如果一個類型不能被修改為允許這類的訪問,訪問方法可以禁止訪問: > If a type cannot be modi?ed to allow this kind of access, the accessing method may force access: ~~~ class MyClass { static private var foo: Int; } class Main { @:access(MyClass.foo) static public function main() { MyClass.foo; } } ~~~ @:access(MyClass.foo) 注釋在main方法中有效的顛覆了foo字段的可見性。 > The @:access(MyClass.foo) annotation effectively subverts the visibility of the foo ?eld within the main-method. **元數據的選擇** >[warning] 花絮:元數據的選擇 訪問控制語言特性使用 Haxe元數據語法,而不是額外的語言特定語法。有如下幾個理由: 另外的語法通常使得語言解析更加復雜,也會添加太多關鍵字。 另外的語法需要另外的學習成本,元數據語法是已知的知識。 元數據語法足夠靈活來擴展這個功能。 元數據可以被通過Haxe的宏 訪問/生成/修改。 當然,使用元數據語法主要的缺點是,如果你拼錯元數據的關鍵字(例如@:acesss)或者類/包的名將不會得到錯誤報告。然而,通過這個功能,當你嘗試訪問一個不被允許的私有字段,你會得到一個錯誤,畢竟不可能是一個不被察覺的錯誤。 >[warning] **Trivia**: On the choice of metadata The access control language feature uses the Haxe metadata syntax instead of additional language-speci?c syntax. There are several reasons for that: > * Additional syntax often adds complexity to the language parsing, and also adds (too) many keywords. > * Additional syntax requires additional learning by the language user,whereas metadata syntax is something that is already known. > * The metadata syntax is ?exible enough to allow extension of this feature. > * The metadata can be accessed/generated/modi?ed by Haxe macros. > Of course, the main drawback of using metadata syntax is that you get no error report in case you misspell either the metadata key (@:acesss for instance) or the class/package name. However, with this feature you will get an error when you try to access a private ?eld that you are not allowed to, therefore there is no possibility for silent errors. **Haxe 3.1.0 以后** > **Since Haxe 3.1.0** 如果允許訪問一個 接口(第2.3.3節),它延伸到所有實現這個接口的類: > If access is allowed to an interface(2.3.3),it extends to all classes implementing that interface: ~~~ class MyClass { @:allow(I) static private var foo: Int; } interface I { } class Main implements I { static public function main() { MyClass.foo; } } ~~~ 對于訪問授權父類,也是同樣的,這種情況會延伸到所有的子類: > This is also true for access granted to parent classes, in which case it extends to all child classes. **破壞性功能** >[warning] **花絮**:破壞性功能 子類和實現類的訪問擴展只支持Haxe 3.0以后。當編寫這本手冊時發現這部分的訪問控制實現是容易缺失的。 >[warning] **Trivia**: Broken feature Access extension to child classes and implementing classes was supposed to work in Haxe 3.0 and even documented accordingly. While writing this manual it was found that this part of the access control implementation was simply missing.
                  <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>

                              哎呀哎呀视频在线观看