HaxeDoc2

(やまだぃちぅ) #1

  • The bottommost import takes priority (detailed inResolution Order(Section 3.7.3)).

  • The static extension (6.3) keywordusingimplies the effect ofimport.

  • 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 theOpAddusage in the above example).


Furthermore, it is also possible to import static fields ( 4 ) of a class and use them unqualified:
1 import Math.random;
2
3 class Main {
4 static public function main() {
5 random();
6 }
7 }

Describe import a.Describe import a.
Special care has to be taken with field names or local variable names that conflict with a
package name: Since they take priority over packages, a local variable namedhaxeblocks off
usage the entirehaxepackage.


3.7.3 Resolution Order


Resolution order comes into play as soon as unqualified identifiers are involved. These are ex-
pressions ( 5 ) in the form offoo(),foo = 1andfoo.field. The last one in particular includes
module paths such ashaxe.ds.StringMap, wherehaxeis an unqualified identifier.
We describe the resolution order algorithm here, which depends on the following state:


  • the declared local variables (5.10) (including function arguments)

  • the imported (3.7.2) modules, types and statics

  • the available static extensions (6.3)

  • the kind (static or member) of the current field

  • the declared member fields on the current class and its parent classes

  • the declared static fields on the current class

  • the expected type (3.6.1)

  • the expression beinguntypedor not


proper label and cap-
tion + code/identifier
styling for diagram


proper label and cap-
tion + code/identifier
styling for diagram


Given an identifieri, the algorithm is as follows:

1.If i istrue,false,this,superornull, resolve to the matching constant and halt.

2.If a local variable namediis accessible, resolve to it and halt.

3.If the current field is static, go to 6.

4.If the current class or any of its parent classes has a field namedi, resolve to it and halt.

5.If a static extension with a first argument of the type of the current class is available, resolve
to it and halt.
Free download pdf