6.2 ECMAScript Specification Types 规范类型
原文:A specification type corresponds to meta-values that are used within algorithms to describe the semantics of ECMAScript language constructs and ECMAScript language types. The specification types include Reference, List, Completion, Property Descriptor, Lexical Environment, Environment Record, and Data Block. Specification type values are specification artefacts that do not necessarily correspond to any specific entity within an ECMAScript implementation. Specification type values may be used to describe intermediate results of ECMAScript expression evaluation but such values cannot be stored as properties of objects or values of ECMAScript language variables.
译文:规范类型对应算法中用于描述ECMAScript结构及语言类型语义的元值。这些规范类型包括引用,列表,完成,属性描述,词法环境,环境记录和数据块。规范类型的值都是规范影射的意义,不需要对应任何ECMAScript运行中的特定实例。规范类型的值可能用来描述ECMAScript表达式运行的中间结果,但是这些结果是不能被对象的属性或是语言变量储存的。
6.2.1 The List and Record Specification Types
原文:The List type is used to explain the evaluation of argument lists (see 12.3.6) in new expressions, in function calls, and in other algorithms where a simple ordered list of values is needed. Values of the List type are simply ordered sequences of list elements containing the individual values. These sequences may be of any length. The elements of a list may be randomly accessed using 0-origin indices. For notational convenience an array-like syntax can be used to access List elements. For example, arguments[2] is shorthand for saying the 3rd element of the List arguments.
译文:List列表类型用来解释诸如new表达式,函数调用和一些需要简单有序列表值的算法中的参数列表的运算的。List类型的值是包含各个值列表元素的一组简单有序的序列。这个序列长度不定。列表元素可以通过以0为起点的任意索引值访问。通过List元素可以方便的表述任何类数组的序列。例如arguments[2]就是arguments List的第3个元素的缩写。
原文:For notational convenience within this specification, a literal syntax can be used to express a new List value. For example, ? 1, 2 ? defines a List value that has two elements each of which is initialized to a specific value. A new empty List can be expressed as ? ?.
译文:为方便表述这个规范,字面序列语法可以用来表达一个新的List值。例如<<1,2>>定义了一个List值包含两个已经初始化为特定值的元素。一个新的空LIst可以表达为<<>>。
原文:The Record type is used to describe data aggregations within the algorithms of this specification. A Record type value consists of one or more named fields. The value of each field is either an ECMAScript value or an abstract value represented by a name associated with the Record type. Field names are always enclosed in double brackets, for example [[Value]].
译文:Record类型是用来描述该规范的算法中数据聚合。Record类型的值包括一个或多个命名的字段。每个字段的值是ECMAScript的值或者是由Record类型关联名称表示的抽象值。字段名称总是利用双括号表示,如[[Value]]。
原文:For notational convenience within this specification, an object literal-like syntax can be used to express a Record value. For example, { [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty } defines a Record value that has three fields, each of which is initialized to a specific value. Field name order is not significant. Any fields that are not explicitly listed are considered to be absent.
译文:为了规范中便于表述,Record类型可以用一个类对象字面量的序列表示。例如{ [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty }定义了一个Record值,包含三个字段,每个字段都初始化为特定的值,字段的顺序没有明显意义。任何没有被明确列出的字段都被认为是不存在的。
原文:In specification text and algorithms, dot notation may be used to refer to a specific field of a Record value. For example, if R is the record shown in the previous paragraph then R.[[Field2]] is shorthand for “the field of R named [[Field2]]”.
译文:在规范文本和算法中,点标记可以用来引用Record值中特定的字段。如,R是之前出现的一个记录,那么R.[[Field2]]就是“R中名为[[Field2]]的字段”的简称。
原文:Schema for commonly used Record field combinations may be named, and that name may be used as a prefix to a literal Record value to identify the specific kind of aggregations that is being described. For example: PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }.
译文:Record字段常用组合模式是命名式,这种命名被当做一个Record字面量的前缀,用于标记一类特定的聚合描述。如PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }。
6.2.2 The Set and Relation Specification Types
原文:The Set type is used to explain a collection of unordered elements for use in the memory model. Values of the Set type are simple collections of elements, where no element appears more than once. Elements may be added to and removed from Sets. Sets may be unioned, intersected, or subtracted from each other.
译文:Set类型用来表示内存模型使用的一组无序元素集合。Set类型的值是简单的元素集合,其中元素都是唯一的。元素可以从集合中添加或删除。集合之间可以合并,相交或相减。
原文:The Relation type is used to explain constraints on Sets. Values of the Relation type are Sets of ordered pairs of values from its value domain. For example, a Relation on events is a set of ordered pairs of events. For a Relation R and two values a and b in the value domain of R, a R b is shorthand for saying the ordered pair (a, b) is a member of R. A Relation is least with respect to some conditions when it is the smallest Relation that satisfies those conditions.
译文:Relation类型是用来表示集合中的约束关系。Relation类的值是值域中有序对的值的集合。例如,事件的Relation是事件的有序对集合。对于一个Relation R和其值域中的两个值a,b。a R b是R的有序对(a,b)的简称。Relation至少遵循某些条件,即这些条件能够满足最小的Relation。
原文:A strict partial order is a Relation value R that satisfies the following.
- For all a, b, and c in R's domain:
-
- It is not the case that a R a, and
- If a R b and b R c, then a R c.
NOTE 1 The two properties above are called, in order, irreflexivity and transitivity.
译文:一个严谨的偏序是满足如下条件的Relation值R:
- 在R中的所有a,b,c:
- 不会出现a R a的情况,并且
- 如果a R b 且 b R c, 则 a R c。
注释1:以上两种属性也被成为非自反性和传递性。
原文:A strict total order is a Relation value R that satisfies the following.
- For all a, b, and c in R's domain:
-
- a is identical to b or a R b or b R a, and
- It is not the case that a R a, and
- If a R b and b R c, then a R c.
NOTE 2 The three properties above are called, in order, totality, irreflexivity, and transitivity.
译文: 一个严谨的总序是满足如下条件的Relation值R:
- 在R中的所有a,b,c:
- a 恒等于b 或 a R b 或 b R a, 并且
- 不会出现 a R a的情况,并且
- 如果a R b 且 b R c, 则 a R c。
注释2: 以上三种属性也成为总体性,非自反性和传递性。