From e2c96135e86ffe8e62adad1531ab4e3b27d1db45 Mon Sep 17 00:00:00 2001 From: JD Liu Date: Sat, 23 Dec 2017 21:53:28 +0800 Subject: [PATCH] translated: issue #8 --- translated/issues-8.html | 130 +++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/translated/issues-8.html b/translated/issues-8.html index 511872c4a1..c4dc2c1b0f 100644 --- a/translated/issues-8.html +++ b/translated/issues-8.html @@ -1,8 +1,8 @@ - -

Algorithm Conventions

-

The specification often uses a numbered list to specify steps in an algorithm. These algorithms are used to precisely specify the required semantics of ECMAScript language constructs. The algorithms are not intended to imply the use of any specific implementation technique. In practice, there may be more efficient algorithms available to implement a given feature.

-

Algorithms may be explicitly parameterized, in which case the names and usage of the parameters must be provided as part of the algorithm's definition.

-

Algorithm steps may be subdivided into sequential substeps. Substeps are indented and may themselves be further divided into indented substeps. Outline numbering conventions are used to identify substeps with the first level of substeps labelled with lower case alphabetic characters and the second level of substeps labelled with lower case roman numerals. If more than three levels are required these rules repeat with the fourth level using numeric labels. For example:

+ +

算法约定

+

此规范通常使用带编号的列表来指定算法的步骤。这些算法是用来精确地指定 ECMAScript 语言结构所需的语义。该算法无意暗示任何具体实现使用的技术。在实践中,也许可用更有效的算法实现一个给定功能。

+

算法也许被显式的参数化,在这些案例中参数的名称和用法必须作为算法定义的一部分提高。

+

算法步骤也许被细分成多个连续的子步骤。子步骤需要用缩进表示,并且也许会进一步被划分成更小的缩进的子步骤。大纲编号约定被用作标识有小写字母字符标签的一级子步骤以及有小写罗马数字标签的二级子步骤。如果超过步骤3级,那么这些规则从第四级开始用数字标签进行重复。例如:

1. Top-level step 1. Substep. @@ -12,109 +12,109 @@

Algorithm Conventions

1. Subsubsubsubstep 1. Subsubsubsubsubstep
-

A step or substep may be written as an “if” predicate that conditions its substeps. In this case, the substeps are only applied if the predicate is true. If a step or substep begins with the word “else”, it is a predicate that is the negation of the preceding “if” predicate step at the same level.

-

A step may specify the iterative application of its substeps.

-

A step that begins with “Assert:” asserts an invariant condition of its algorithm. Such assertions are used to make explicit algorithmic invariants that would otherwise be implicit. Such assertions add no additional semantic requirements and hence need not be checked by an implementation. They are used simply to clarify algorithms.

-

Algorithm steps may declare named aliases for any value using the form “Let _x_ be _someValue_”. These aliases are reference-like in that both _x_ and _someValue_ refer to the same underlying data and modifications to either are visible to both. Algorithm steps that want to avoid this reference-like behaviour should explicitly make a copy of the right-hand side: “Let _x_ be a copy of _someValue_” creates a shallow copy of _someValue_.

-

Once declared, an alias may be referenced in any subsequent steps and must not be referenced from steps prior to the alias's declaration. Aliases may be modified using the form “Set _x_ to _someOtherValue_”.

+

一个步骤或者子步骤也许会使用“if”去断言它的子步骤的条件。在这样的案例中,这些子步骤只能适用于“if”断言为真的情况。如果一个步骤或者子步骤以“else”开始,那么表示这是之前的“if”断言的同一级的否定断言。

+

一个步骤也许会指定它的子步骤的迭代程序。

+

一个以“Assert:”开头的步骤断言一个它的算法里不变的条件。这样的断言被用作使算法不变量显式地展示,否则它将是隐式的。这样的断言不增加额外的语义需求,因此在实现中不需要被检查。它们被使用只是为了使算法更清晰。

+

对于任意形如“Let _x_ be _someValue_”的值,算法步骤也许会声明命名别名。这些别名即可能通过_x_也可能通过_someValue_引用,它们指向同一个潜在的数据,并且修改其中任意一个对另一个都是可见的。那些想避免这样的类似引用的算法步骤需要显式地复制一份右值:即“Let_x_ be a copy of _someValue_”创建了一个_someValue_的浅复制。

+

一旦声明完毕,别名也许会在随后的任意步骤或者子步骤中被引用,但是它们也许不会在最高级步骤中被引用。别名也许会通过形如“Set _x_ to _someOtherValue_”这样的形式被修改。

-

Abstract Operations

-

In order to facilitate their use in multiple parts of this specification, some algorithms, called abstract operations, are named and written in parameterized functional form so that they may be referenced by name from within other algorithms. Abstract operations are typically referenced using a functional application style such as OperationName(_arg1_, _arg2_). Some abstract operations are treated as polymorphically dispatched methods of class-like specification abstractions. Such method-like abstract operations are typically referenced using a method application style such as _someValue_.OperationName(_arg1_, _arg2_).

+

抽象操作

+

为了促进它们在本规范的多个地方使用,一些算法,我们称之为抽象操作,在参数化的函数形式中中命名和书写,以便它们能够在其它算法中通过名称来引用。抽象操作通常是被通过一个功能化的应用风格引用,如 OperationName(_arg1_, _arg2_)。一些抽象操作被当作像类规范里抽象的多态发送一样。这样的类似类的方法抽象操作通常通过一个方法应用风格被引用,如_someValue_.OperationName(_arg1_, _arg2_)。

-

Syntax-Directed Operations

-

A syntax-directed operation is a named operation whose definition consists of algorithms, each of which is associated with one or more productions from one of the ECMAScript grammars. A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative. When an algorithm is associated with a grammar production, it may reference the terminal and nonterminal symbols of the production alternative as if they were parameters of the algorithm. When used in this manner, nonterminal symbols refer to the actual alternative definition that is matched when parsing the source text.

-

When an algorithm is associated with a production alternative, the alternative is typically shown without any “[ ]” grammar annotations. Such annotations should only affect the syntactic recognition of the alternative and have no effect on the associated semantics for the alternative.

-

Syntax-directed operations are invoked with a parse node and, optionally, other parameters by using the conventions on steps 1, 3, and 4 in the following algorithm:

+

特定语法操作

+

一个特定语法操作是一个具有名称的操作,它的定义包含了一系列算法,每个算法与一个或者多个ECMAScript文法的产生式相关联。一个有多个可选定义的产生式通常对于每个可选部分都有一个独立的算法。当一个算法与一个文法产生式相关联的时候,它也许会引用这个产生式可选部分的终结符或者非终结符,就好像它们是这个算法的参数一样。当出现这种情况时,非终结符指向实际的源代码中与之匹配的可选部分的定义。

+

当一个算法与一个产生式的可选部分关联的时候,这个可选部分通常不会带上“[ ]”文法注释。这样的注释只应该影响可选部分的语法识别,不应该对相关的可选部分的语义有影响。

+

特定语法操作同一个解析节点一起被调用,还可以在步骤1,3,4中使用这个约定的其它参数:

1. Let _status_ be the result of performing SyntaxDirectedOperation of |SomeNonTerminal|. 2. Let _someParseNode_ be the parse of some source text. 2. Perform SyntaxDirectedOperation of _someParseNode_. 2. Perform SyntaxDirectedOperation of _someParseNode_ passing `"value"` as the argument. -

Unless explicitly specified otherwise, all chain productions have an implicit definition for every operation that might be applied to that production's left-hand side nonterminal. The implicit definition simply reapplies the same operation with the same parameters, if any, to the chain production's sole right-hand side nonterminal and then returns the result. For example, assume that some algorithm has a step of the form: “Return the result of evaluating |Block|” and that there is a production:

+

除非显式地指定,否则,所有相关联的产生式对于每个也许会被应用到这个产生式左值的非终结符的操作都有一个隐式的定义。如果存在的话,这个隐式的定义简单地再次对同样的参数运用这个相同的定义,对于这些相关联的产生式唯一的右值非终结符,随后返回处理结果。例如,假设一些算法有如下形式的步骤:“返回被解析的块的结果(Return the result of evaluating Block)”,并且这里有一个产生式:

Block : `{` StatementList `}` -

but the Evaluation operation does not associate an algorithm with that production. In that case, the Evaluation operation implicitly includes an association of the form:

-

Runtime Semantics: Evaluation

+

但是解析操作并没有关联这个产生式的算法。那么在这样的案例中,解析操作隐式地包含了下面形式的关联:

+

运行时语义: 解析

Block : `{` StatementList `}` 1. Return the result of evaluating |StatementList|.
- + -

Runtime Semantics

-

Algorithms which specify semantics that must be called at runtime are called runtime semantics. Runtime semantics are defined by abstract operations or syntax-directed operations. Such algorithms always return a completion record.

+

运行时语义

+

必须在运行时被调用的指定语义的算法就叫运行时语义。 运行时语义通过抽象操作或者指定语法操作来定义。这样的算法必须返回一个完成记录。

-

Implicit Completion Values

-

The algorithms of this specification often implicitly return Completion Records whose [[Type]] is ~normal~. Unless it is otherwise obvious from the context, an algorithm statement that returns a value that is not a Completion Record, such as:

+

隐式完成值

+

本规范的算法常常隐式地返回一个[[Type]]值为normal的完成记录。除非它是上下文中另外非常明显的部分,一个返回一个值的算法语句,那么这个值将不是一个完成值。例如:

1. Return `"Infinity"`. -

means the same thing as:

+

与下面的是同一个含义:

1. Return NormalCompletion(`"Infinity"`). -

However, if the value expression of a “return” statement is a Completion Record construction literal, the resulting Completion Record is returned. If the value expression is a call to an abstract operation, the “return” statement simply returns the Completion Record produced by the abstract operation.

-

The abstract operation Completion(_completionRecord_) is used to emphasize that a previously computed Completion Record is being returned. The Completion abstract operation takes a single argument, _completionRecord_, and performs the following steps:

+

然而,如果一个“return”语句的值表达式是一个完成记录构造的字面量,那么完成记录的结果将被返回。如果这个值表达式是一个对抽象操作的调用,那么“return”语句简单地返回这个抽象操作产生的完成记录。

+

抽象操作Completion(_completionRecord_)被用作强调之前计算的Completion Record被返回。Completion这个抽象操作接收一个参数,即_completionRecord_,然后执行下面的步骤:

1. Assert: _completionRecord_ is a Completion Record. 1. Return _completionRecord_ as the Completion Record of this abstract operation. -

A “return” statement without a value in an algorithm step means the same thing as:

+

一个在算法步骤中没有值的“return” 语句与下面的是同样的意思:

- 1. Return NormalCompletion(*undefined*). + 1. Return NormalCompletion(`undefined`). -

Any reference to a Completion Record value that is in a context that does not explicitly require a complete Completion Record value is equivalent to an explicit reference to the [[Value]] field of the Completion Record value unless the Completion Record is an abrupt completion.

+

对于任意的在一个上下文中没有显示地需要一个完整的Completion Record值的引用,等价于一个显式地对Completion Record的[[Value]]字段的引用,除非Completion Record是一个打断/中断完成。

- + -

Throw an Exception

-

Algorithms steps that say to throw an exception, such as

+

抛出一个异常

+

描述抛出一个异常的算法步骤,例如:

- 1. Throw a *TypeError* exception. + 1. Throw a `TypeError` exception. -

mean the same things as:

+

意思就是:

- 1. Return Completion{[[Type]]: ~throw~, [[Value]]: a newly created *TypeError* object, [[Target]]: ~empty~}. + 1. Return Completion{[[Type]]: throw, [[Value]]: a newly created `TypeError` object, [[Target]]: empty}.
- + -

ReturnIfAbrupt

-

Algorithms steps that say or are otherwise equivalent to:

+

返回

+

算法步骤说明或者等同于:

1. ReturnIfAbrupt(_argument_). -

mean the same thing as:

+

意思就是:

1. If _argument_ is an abrupt completion, return _argument_. 1. Else if _argument_ is a Completion Record, let _argument_ be _argument_.[[Value]]. -

Algorithms steps that say or are otherwise equivalent to:

+

算法步骤说明或者等同于:

1. ReturnIfAbrupt(AbstractOperation()). -

mean the same thing as:

+

意思就是:

1. Let _hygienicTemp_ be AbstractOperation(). 1. If _hygienicTemp_ is an abrupt completion, return _hygienicTemp_. 1. Else if _hygienicTemp_ is a Completion Record, let _hygienicTemp_ be _hygienicTemp_.[[Value]]. -

Where _hygienicTemp_ is ephemeral and visible only in the steps pertaining to ReturnIfAbrupt.

-

Algorithms steps that say or are otherwise equivalent to:

+

这里的_hygienicTemp_是短暂的(临时的),并且只在ReturnIfAbrupt有关的步骤中中可见。

+

算法步骤说明或者等同于:

1. Let _result_ be AbstractOperation(ReturnIfAbrupt(_argument_)). -

mean the same thing as:

+

意思就是:

1. If _argument_ is an abrupt completion, return _argument_. 1. If _argument_ is a Completion Record, let _argument_ be _argument_.[[Value]]. @@ -122,34 +122,34 @@

ReturnIfAbrupt

-

ReturnIfAbrupt Shorthands

-

Invocations of abstract operations and syntax-directed operations that are prefixed by `?` indicate that ReturnIfAbrupt should be applied to the resulting Completion Record. For example, the step:

+

如果被打断则返回 缩写

+

对抽象操作和以`?`为前缀的指定语法操作的调用暗示着ReturnIfAbrupt需要被应用到结果的Completion Record中。 例如,步骤:

1. ? OperationName(). -

is equivalent to the following step:

+

等价于下面的步骤:

1. ReturnIfAbrupt(OperationName()). -

Similarly, for method application style, the step:

+

相似的,对于程序方法的风格,步骤:

1. ? _someValue_.OperationName(). -

is equivalent to:

+

等价于:

1. ReturnIfAbrupt(_someValue_.OperationName()). -

Similarly, prefix `!` is used to indicate that the following invocation of an abstract or syntax-directed operation will never return an abrupt completion and that the resulting Completion Record's [[Value]] field should be used in place of the return value of the operation. For example, the step:

+

相似的,前缀`!`被用作暗示下列的对于抽象或者指定语法操作的调用将不会返回一个打断的完成值, 并且作为结果的Completion Record的[[Value]]字段应该被用作替换操作的返回值。 例如,步骤:

1. Let _val_ be ! OperationName(). -

is equivalent to the following steps:

+

等价于下面的步骤:

1. Let _val_ be OperationName(). 1. Assert: _val_ is never an abrupt completion. 1. If _val_ is a Completion Record, set _val_ to _val_.[[Value]]. -

Syntax-directed operations for runtime semantics make use of this shorthand by placing `!` or `?` before the invocation of the operation:

+

对于运行时语义的指定语法的操作通过在调用操作前替换`!`或者`?`来利用这个缩写。

1. Perform ! SyntaxDirectedOperation of |NonTerminal|. @@ -157,10 +157,10 @@

ReturnIfAbrupt Shorthands

-

Static Semantics

-

Context-free grammars are not sufficiently powerful to express all the rules that define whether a stream of input elements form a valid ECMAScript |Script| or |Module| that may be evaluated. In some situations additional rules are needed that may be expressed using either ECMAScript algorithm conventions or prose requirements. Such rules are always associated with a production of a grammar and are called the static semantics of the production.

-

Static Semantic Rules have names and typically are defined using an algorithm. Named Static Semantic Rules are associated with grammar productions and a production that has multiple alternative definitions will typically have for each alternative a distinct algorithm for each applicable named static semantic rule.

-

Unless otherwise specified every grammar production alternative in this specification implicitly has a definition for a static semantic rule named Contains which takes an argument named _symbol_ whose value is a terminal or nonterminal of the grammar that includes the associated production. The default definition of Contains is:

+

静态语义

+

上下文无关文法不能足够好的去表达所有定义的规则, 不管是一个输入元素的流形成的一个合法的将被解析的ECMAScript |Script|还是|Module|。 在一些情况中,需要额外的规则通过使用ECMAScript算法约定或者散文要求来展示。这样的规则总是与一个文法的产生式相关联,被称作产生式的静态语义

+

静态语义规则拥有名称,并且通常用一个算法来定义。 具有名称的静态语义规则与文法产生式相关联,对于每个可采用的具有名称的静态语义规则, 一个包含多个可选部分定义的产生式通常会对每个可选部分定义一个独有的算法。

+

除非在本规范中其它指定的文法产生式可选部分隐式地包含一个叫做Contains的接收一个值为包含相关产生式的文法的终结符或者非终结符的_symbol_参数静态语义规则的定义。 默认的包含定义为:

1. For each child node _child_ of this Parse Node, do 1. If _child_ is an instance of _symbol_, return *true*. @@ -169,16 +169,16 @@

Static Semantics

1. If _contained_ is *true*, return *true*. 1. Return *false*.
-

The above definition is explicitly over-ridden for specific productions.

-

A special kind of static semantic rule is an Early Error Rule. Early error rules define early error conditions (see clause ) that are associated with specific grammar productions. Evaluation of most early error rules are not explicitly invoked within the algorithms of this specification. A conforming implementation must, prior to the first evaluation of a |Script| or |Module|, validate all of the early error rules of the productions used to parse that |Script| or |Module|. If any of the early error rules are violated the |Script| or |Module| is invalid and cannot be evaluated.

+

上面的定义是显式地重写了规范的产生式。

+

一个特殊的静态语义规则是早期(提前)错误规则。早期错误规则定了早期错误条件(见),它们与具体的文法产生式相关联。大多数早期错误规则的解析不是在本规范的算法中显式地被调用。一个符合规范的实现必须在第一次解析|Script|或者|Module|之前,验证所有被用作解析|Script|或者|Module|的产生式的早期错误规则。如果违反了任意的早期错误规则,那么|Script|或者|Module|就是不合法的,并且不能被解析执行。

-

Mathematical Operations

-

Mathematical operations such as addition, subtraction, negation, multiplication, division, and the mathematical functions defined later in this clause should always be understood as computing exact mathematical results on mathematical real numbers, which unless otherwise noted do not include infinities and do not include a negative zero that is distinguished from positive zero. Algorithms in this standard that model floating-point arithmetic include explicit steps, where necessary, to handle infinities and signed zero and to perform rounding. If a mathematical operation or function is applied to a floating-point number, it should be understood as being applied to the exact mathematical value represented by that floating-point number; such a floating-point number must be finite, and if it is *+0* or *-0* then the corresponding mathematical value is simply 0.

-

The mathematical function abs(_x_) produces the absolute value of _x_, which is -_x_ if _x_ is negative (less than zero) and otherwise is _x_ itself.

-

The mathematical function min(_x1_, _x2_, ..., _xN_) produces the mathematically smallest of _x1_ through _xN_. The mathematical function max(_x1_, _x2_, ..., _xN_) produces the mathematically largest of _x1_ through _xN_. The domain and range of these mathematical functions include *+∞* and *-∞*.

-

The notation “_x_ modulo _y_” (_y_ must be finite and nonzero) computes a value _k_ of the same sign as _y_ (or zero) such that abs(_k_) < abs(_y_) and _x_-_k_ = _q_ × _y_ for some integer _q_.

-

The mathematical function floor(_x_) produces the largest integer (closest to positive infinity) that is not larger than _x_.

+

数学操作

+

除非其它地方特别注明不包括无限并且不包括负0(为了与正0区分),数学操作,例如加,减,否定(逻辑非),乘,除以及随后在条款中定义的数学函数应总是被当作是对于数学中所有真实数字计算出来的准确的结果。本规范算法中的浮点运算包含显式地的步骤,它们对于处理无穷,有符号的0,以及舍入是必要的。如果一个数学操作或者函数被应用在一个浮点数上,那么它必须被当作应用到用浮点数表示的具体的数学值;这样的浮点数必须是有限的,并且如果它是`+0`或者`-0`的话,那么相应的数学值就是简简单单的0。

+

数学函数abs(_x_)用来计算_x_的绝对值, 如果_x_是负数,那么结果就是-_x_,否则结果就是_x_本身。

+

数学函数min(_x1_, _x2_, ..., _xN_)计算从_x1__xN_的最小值。 数学函数max(_x1_, _x2_, ..., _xN_)计算从_x1__xN_的最大值。 这些数学函数的域以及范围包括`+∞`和`-∞`。

+

符号“_x_ modulo _y_”(_y_必须是有限的且是非0的)计算出一个值_k_, 它的符号与_y_一致(或者是0),这样的_k_满足abs(k)< abs(y),以及能找到某个整数y,使得_x_-_k_ = _q_ * _y_。

+

The mathematical functionfloor(_x_) produces the largest integer (closest to positive infinity) that is not larger than_x_.

floor(_x_) = _x_-(_x_ modulo 1).