Skip to content

Instantly share code, notes, and snippets.

@nanto
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanto/e8a6e9e02d04df615927 to your computer and use it in GitHub Desktop.
Save nanto/e8a6e9e02d04df615927 to your computer and use it in GitHub Desktop.
ECMAScript 6 草案を斜め読みしていくメモ
https://people.mozilla.org/~jorendorff/es6-draft.html を参照する。
4.3.25
Symbol value が ES 6 で登場。
5.1.5
パラメータ化がたくさん。
StatementList[Return] :
[+Return] ReturnStatement
ExpressionStatement
StatementList :
ExpressionStatement
StatementList_Return :
ReturnStatement
ExpressionStatement
と同じ。
StatementList[Return] :
[~Return] ReturnStatement
ExpressionStatement
StatementList :
ReturnStatement
ExpressionStatement
StatementList_Return :
ExpressionStatement
と同じ。
5.3
static semantic rules なるものが登場。意味解析用?
6.1.5.1
@@species 生物分類での「種」
6.1.7.2
[[Get]] のシグネチャが (propertyKey, Receiver) → any
Receiver (this の値) が登場。[[Set]] にも。
[[Construct]] の第 2 引数に「new 演算子を適用されたオブジェクト」が来る。
6.1.7.4
well-known intrinsic objects (周知の内在オブジェクト?) として
%Array%、%ArrayPrototype% といった記法を導入。
ES5 では "where Array is the standard built-in constructor with that name"
といった長々した注釈をいちいちつけていた。
6.2.2.2
アルゴリズムで Return ... となっている部分は Completion 型を返す略記法。
6.2.2.4
ReturnIfAbrupt、例外ならそのまま上に投げる。そうでなければステップ続行。
引数の保証など。
6.2.6
仕様型として Data Block が登場。バイト列。
7.1.1
ToPrimitive。ES5 にあった [[DefaultValue]] が消えた。
valueOf / toString の前に @@toPrimitive。
7.1.15
ToLength、配列の要素数となりうる範囲の整数。
7.1.16
CanonicalNumericIndexString、
文字列→数値→文字列したとき元の文字列と一致するような文字列。
そうでなければ undefined。
7.2.1
RequireObjectCoercible。undefined、null 以外。
7.2.2
IsArray。Array exotic object。
[[ProxyTarget]] を見ることも。
7.2.8
IsRegExp。@@match または [[RegExpMatcher]] 内部スロット。
7.3.1
Get(O, P)。O はオブジェクト。
7.3.2
GetV(V, P)。V はプリミティブ値かも。
ToObject(V).[[Get]](P, V) を呼び出すので、this に V がそのまま入る。
7.3.5
CreateMethodProperty。[[Enumerable]] が
false になる以外は CreateDataProperty と同じ。
7.3.9
GetMethod。GetV した結果が undefined か null なら
undefined が返る (TypeError にならない)。
それ以外の値で IsCallable が偽なら TypeError。
7.3.13
Construct(F, argumentsList, newTarget)。
newTarget が省略されたら F が使われる
(new F(...argumentsList) と同じ)。
7.3.14
SetIntegrityLevel(O, level)。level は "sealed" か "frozen"。
integrity: 誠実、完全性、整合性。
7.3.16
CreateArrayFromList 内部で ArrayCreate が呼び出される。
7.3.18
Invoke。いわゆるメソッド呼び出し。
7.3.19
OrdinaryHasInstance(C, O)。C.[[BoundTargetFunction]] があれば
InstanceOfOperator を呼び出す。そうでなければプロトタイプをたどる。
7.3.20
SpeciesConstructor(O, defaultConstructor)。
O.constructor.@@species || defaultConstructor みたいな感じ。
7.3.21
EnumerableOwnNames(O)。[[Enumerate]] が返すイテレータと同じ順序。
7.3.22
GetFunctionRealm(obj)。obj は呼び出し可能なオブジェクト。
Components.utils.getGlobalForObject() みたいなものか。
7.4.2
IteratorNext(iterator, value)。
「« »」という記法は何だったっけ? リストっぽい。
7.4.6
IteratorClose(iterator, completion)。
iterator.return() 内で投げられた例外が伝播する?
iterator.return() がオブジェクトを返すことを期待している?
8.1
グローバル環境、モジュール環境、関数環境。
8.1.1.1.8
通常の宣言的環境レコードは this に対する束縛を持たない。
8.1.1.3
関数環境レコード。[[thisBindingStatus]] が "lexical" ならアロー関数。
8.1.1.3.5
GetSuperBase()。envRec.[[HomeObject]].[[GetPrototypeOf]]()。
8.1.1.4
グローバル環境レコード。[[ObjectRecord]] と [[DeclarativeRecord]] を持つ。
各操作でまず [[DeclarativeRecord]] を見てから [[ObjectRecord]] を見たりする。
var や function は [[ObjectRecord]] に、
let や class は [[DeclarativeRecord]] に、それぞれ関連づく?
8.1.1.4.18
CreateGlobalFunctionBinding(N, V, D)。
ステップ 8 で DefinePropertyOrThrow() したあと
ステップ 10 で Set() している。なぜ?
8.1.1.5
モジュール環境レコード。間接束縛 (indirect binding) なるものが登場する。
別名でインポートしても元の基底オブジェクトと名前を保持し続けるのか。
モジュールのインポートにおいては「参照の値渡し」ではなく「参照渡し」になるのか?
8.2
realm: 領域、分野、体系
ウィンドウごとに異なるグローバルオブジェクトを持つみたいな感じ。
8.2.2
CreateIntrinsics(realmRec)。組み込みオブジェクトの初期化。
8.3
注意書きなしの LexicalEnvironment、VariableEnvironment は、
実行中の実行コンテキストのそれを指す。
8.3.1
ResolveBinding(name, [env])。
ここで strict mode code かどうかの判別が行われる。
8.4
実行コンテキストのスタックがからなら次のジョブが実行される。
8.4.2
ジョブに関するアルゴリズムステップでは
Return result ではなく NextJob result が用いられる。
実行中の実行コンテキストを一時停止し (suspend)、
それを実行コンテキストスタックから取り除く。
8.5
スクリプトの評価は ScriptEvaluationJob。
モジュールの評価は TopLevelModuleEvaluationJob。
9.1
通常のオブジェクト (ordinary object) の [[Extensible]] が
一度 true になったら、その後 false にはならない。
ここでの "may not" は「不許可」だよね?
9.1.6.3
ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current)。
[[DefineOwnProperty]] とかの実体。
7.b., 7.c. で [[Configurable]] と [[Enumerable]] の値が保持される。
このことはどんな効果をもたらすのか?
current.[[Configurable]] is true and Desc.[[Configurable]] is true ... ok
current.[[Configurable]] is true and Desc.[[Configurable]] is false ... ok
current.[[Configurable]] is false and Desc.[[Configurable]] is true ... dropped at 5.a.
current.[[Configurable]] is false and Desc.[[Configurable]] is false ... dropped at 7.a.
7.b., 7.c. を通過した後、10.a. で {P of O}.[[Configurable]] = Desc.[[Configurable]] される。
current.[[Configurable]] is true なら [[Writable]] is false なプロパティも書き換え可能。
9.1.8
[[Get]](P, Receiver)。
プロトタイプ上のオブジェクトのプロパティから取得するときは、
parent.[[Get]](P, Receiver) と、引数 Receiver を引き渡す。
9.1.9
[[Set]](P, V, Receiver)。
[[Get]] と同様に Receiver が引き回される。
Receiver 上にプロパティが定義・作成される。
9.1.11
[[Enumerate]]()。
%IteratorPrototype% を継承したオブジェクトを返す。
9.1.12
[[OwnPropertyKeys]]()。
整数インデックスプロパティが最初に来る。
9.2
関数オブジェクトの [[FormalParameters]] が Parse Node 型。
9.2.1.1
PrepareForOrdinaryCall(F, newTarget)。
ステップ 10 で callerContext が既に一時停止されている状況とは?
9.2.1.2
OrdinaryCallBindThis(F, calleeContext, thisArgument)。
この返り値は 9.2.1 の [[Call]] では使われない。
ステップ 3 の calleeRealm はステップ 6 でしか使われない。
9.2.1.3
OrdinaryCallEvaluateBody(F, argumentsList)。
ステップ 3 の EvaluateBody は 14 章で定義される。
9.2.2
[[Construct]](argumentsList, newTarget)。
kind が "base" でなく (派生クラス)、result.[[type]] が return
かつ result.[[value]] が undefined なら、ステップ 13.a ~ 13.c を通過。
このとき、ステップ 15 から呼ばれる envRec.GetThisBinding()
(8.1.1.3.4) で ReferenceError が発生しうる。
9.2.3
FunctionAllocate(functionPrototype, strict [, functionKind])。
F.[[ConstructorKind]] の値は "base" か
"derived" (functionKind が "generator" の場合) か
undefined (functionKind が "non-constructor" の場合)。
F.[[FunctionKind]] の値は "normal" か "generator"。
9.2.5
FunctionCreate(kind, ParameterList, Body, Scope, Strict, prototype)。
FunctionAllocate() してから FunctionInitialize() する。
FunctionAllocate() の第 3 引数に渡す値は、
kind が Normal なら "normal"、
kind が Method か Arrow なら "non-constructor"。
9.2.7
AddRestrictedFunctionProperties(F, realm)。
Function.caller、Function.arguments プロパティは残すが、
アクセスしても TypeError が投げられるだけ。
9.2.8
MakeConstructor(F, writablePrototype, prototype)。
関数 F に対して、F.prototype を設定する。
F.prototype と F.prototype.constructor の
[[Writable]] は一致する (writablePrototype により決定される)。
F.prototype の [[Configurable]] は fales。
9.2.10
MakeMethod(F, homeObject)。
F.[[HomeObject]] = homeObject。
9.2.11
SetFunctionName(F, name, prefix)。
name が Symbol で name.[[Description]] があれば
'[' + name.[[Description]] + ']'。
prefix が与えられ、かつ name が空文字列になるような状況があれば、
最終的に name がスペース文字で終わる。
9.2.12
FunctionDeclarationInstantiation(func, argumentsList)。
実行コンテキストが設置されるとき。長い。
ステップ 23 の iteratorRecord は何か?
後で出てくる IteratorBindingInitialization で使われるらしい。
ステップ 28 によれば、仮引数リスト中の式から作られた
クロージャからは、関数本体の宣言が見えない。
9.3
組み込み関数オブジェクト。
ECMAScript 関数オブジェクトか外来関数オブジェクト。
9.3.1
[[Call]](thisArgument, argumentsList)。
ステップ 9 において、実装で定義された方法で F を評価する。
9.4.1.2
束縛された関数の外来オブジェクト (bound function exotic object) の
[[Construct]](argumentsList, newTarget)。
[[BoundThis]] は使われない。
ステップ 5 により、束縛された関数の外来オブジェクト F が
最終的な newTarget になることはない。
9.4.2.1
配列外来オブジェクト (array exotic object) の
[[DefineOwnProperty]](P, Desc)。
ステップ 3 の if P is an array index の
"array index" ってどこかで定義されていたか?
ステップ 3.i の successed が false になるのは
A.[[Extensible]] が false のとき? ほかにはあるか?
9.4.2.3
ArraySpeciesCreate(originalArray, length)。
ステップ 6.c.iv.1 は NOTE で言及されている部分。
他 Realm の Array でなく実行中の
実行コンテキストの Realm の Array が使われる。
他 Realm の Array を継承したオブジェクトなら
それがそのまま使われる。
ステップ 6.d.1 で C = C.@@species している。
@@species の初期値とかどうなっていたか?
9.4.3.1.1
StringGetIndexProperty(S, P)。
ステップ 6 で S["-0"] をはじく。
S[-0] は String(-0) が "0" だから通る。
返されるプロパティ記述子は [[Enumerable]] が true。
9.4.3.2
string exotic object の [[HasProperty]](P)。
StringGetIndexProperty(S, P) してから
OrdinaryHasProperty(S, P) にフォールバック。
[[GetOwnProperty]] のときとはフォールバックの順序が逆。
9.4.3.3
文字列外来オブジェクト (string exotic object) の
[[OwnPropertyKeys]]()。
負の整数は "is not an integer index" に含まれるのだったっけ?
9.5
プロキシオブジェクト。
> An ECMAScript implementation must be robust in the presence of all possible invariant violations.
実装は不変条件違反を考慮しなければいけない? つらそう。
9.5.15
ProxyCreate(target, handler)。
ステップ 2 とステップ 4 の制約は何のため?
そもそも「[[ProxyHandler]] が null である Proxy 外来オブジェクト」なんて生成できるの?
10.2
関数コード (function code) は関数の
[[ECMAScriptCode]] だけでなく [[FormalParameters]] も含む。
10.2.1
クラス関係は厳格モードコード (strict mode code)。
10.2.2
> Whether a function object is an ECMAScript code function
> or a non-ECMAScript function is not semantically observable
> from the perspective of an ECMAScript code function
> that calls or is called by such a non-ECMAScript function.
Function#toString や new Error().stack での判別は
"sematically observable" には当たらないの?
11.3
NEL (U+0085) は行終端子 (line terminator) に含まれない。
NEL の Unicode カテゴリは Cc だから空白文字にも含まれないはず。
11.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment