Haxe中的表达式定义了程序需要做什么。多数表达式可以在方法(第4.3节)体中找到,它们被结合来描述方法的功能。本节解释不同类型的表达式。一些定义可以提供帮助:
Expressions in Haxe define what a program does. Most expressions are found in the body of a method (4.3), where they are combined to express what that method should do. This section explains the different kinds of expressions. Some definitions help here:
Name
定义:Name 一个名称通常指代
- 一个类型
- 一个局部变量
- 一个局部函数,或者
- 一个字段
Definition: Name A general name may refer to
- a type,
- a local variable,
- a local function or
- a field.
Identifier
定义:标识符 Haxe的标识符由一个下划线_、一个美元符号$,一个小写字母a-z或者一个大写字母A-Z开始。后可接任意数量的数字、下划线、大小写字母的组合。更多的限制受制于使用的上下文,根据类别进行检查: 类型名必须使用大写的字母或者一个下划线开始。 美元符号不允许用于任何类别的名字的开头(美元名字多数用于宏的具体化(第9.3节))。 [warning] Definition: Identifier Haxe identifiers start with an underscore _, a dollar $, a lower-case character a-z or an upper-case character A-Z. After that, any combination and number of _, A-Z, a-z and 0-9 may follow. Further limitations follow from the usage context, which are checked upon typing:
- Type names must start with an upper-case letter A-Z or an underscore _.
- Leading dollars are not allowed for any kind of name(5)(dollar-names are mostly used for macro reification (9.3)).
Since Haxe 3.3.0
Haxe保留前置 hx 的标识符在内部使用。这并不是强制的被解析器或者类型检查器执行。
Haxe reserves the identifier prefix hx for internal use. This is not enforced by the parser or typer.
关键字:下面的Haxe关键字不能被使用为标识符:
Keywords The following Haxe keywords may not be used as identifiers:
- abstract
- break
- case
- cast
- catch
- class
- continue
- default
- do
- dynamic
- else
- enum
- extends
- extern
- false
- for
- function
- if
- implements
- import
- in
- inline
- interface
- macro
- new
- null
- override
- package
- private
- public
- return
- static
- switch
- this
- throw
- true
- try
- typedef
- untyped
- using
- var
- while