Clarification regarding Completion Records

Michael Dyck jmdyck at
Fri Sep 23 16:51:52 UTC 2016

On 16-09-23 10:24 AM, Felix Kling wrote:
> I read these paragraphs over and over again ;) Maybe I just need someone to
> explain it to me in different words.
> So to apply these to my case:
> - `ResolveBinding` is an *"abstract operation"* so it returns a completion
> record, whose value is a *"Reference"*, even though completion records are
> only supposed to have language values as value (6.2.2) (this still confuses me)

The spec is not consistent in this area. That is, these statements are not 
  * Every call to an abstract operation returns a completion record.
  * Every completion record's [[Value]] is a language value or ~empty~.
  * Some abstract operations (e.g. ResolveBinding) need to convey values to
    the caller that are neither language values nor ~empty~.

(See for more examples, and for 
possible ways of resolving the inconsistency.)

> - In `Let exprRef be the result of evaluating Expression`, `exprRef` is a
> Reference, the completion record obtained by *"evaluating Expression"* was
> implicitly unwrapped, according to *"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."`
> Am I right so far?

Not entirely. Here's another way to look at it. If the implicit rule of were made explicit, we would have something like:
     Let exprRef be maybe-unwrap(the result of evaluating Expression).

where maybe-unwrap(cr) is a shorthand for:
   * cr, if cr is an abrupt completion, or
   * cr.[[Value]] if cr is a normal completion.

So (theoretically), for any given execution of this algorithm step, `exprRef` 
is either a Reference or an abrupt completion.

In this case, things also work if you ignore (so that `exprRef` is 
always a Completion Record), because the subsequent call to GetValue() starts 
with a call to ReturnIfAbrupt(), which accomplishes the unwrapping.

> Then, does the sentence
>> The algorithms of this specification often implicitly return Completion
>> Records whose `[[Type]]` is `normal`.
> mean that
> 1. Algorithms may or may not return a completion record (i.e. some do and some
> don't).
> 2. Algorithms *always* return a completion record, but it's not always
> *explicitly* stated in the algorithm.

Statement 2 would result in a similar inconsistency to the one noted above 
(just replacing "abstract operation" with "algorithm").

Statement 1 doesn't have that problem, but it still has the problem of fitting 
into the world in which the 'abstract operation' inconsistency exists.


More information about the es-discuss mailing list