ECMAScript仕様輪読会 #38
前回: ECMAScript仕様輪読会 #37
Scrapboxの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
Discord: https://discord.gg/59S3y6weQj
ES Spec Draft: https://tc39.es/ecma262/
読み物リスト
Twitter hashtag: #esspec
便利ツール
esspec-memo: https://tars0x9752.github.io/esspec-memo/esspec.html
Scrapbox Codeblock Generator: https://vzvu3k6k.github.io/scrapbox-codeblock/
TC39 Terminology: https://github.com/tc39/how-we-work/blob/main/terminology.md
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
引っ越した
部屋が段ボールまみれ
京都に行ってきた
Kyoto.go楽しかったです
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
手首、少し良くなってきた
すごい久々
北海道旅行に行ってきました
yebis0942 (えびす) yebis0942.icon
Go, Reactを書いて暮らしています
近況としてはなぜか外部ディスプレイが認識されない
OpenAI ドキュメント輪読会 #13 - connpass
https://platform.openai.com/docs/ を完走しました
https://platform.openai.com/docs/guides/gpt-best-practices が面白い
OpenAIのAPIのプロンプトのうまい工夫の仕方とか、タスクの分解テクニックとか
antisatori
フィヨルドブートキャンプで学習している無職です
フロントエンドが好きでReactをよく書いてます
最近 Crafting Interpreters を読んでコンパイラーを作ってます
yasumura / harupiyo
Google Chrome のバグ報告しました
https://bugs.chromium.org/p/chromium/issues/detail?id=1462244
前回のあらすじ
難しかったですね…
今回の範囲
9.10 Processing Model of WeakRef and FinalizationRegistry Targets の 9.10.3 Execution から
9.10.3 Execution
an ECMAScript implementation may perform...
"may"が出てくるのは珍しい感
9.10以降はスッと飛ばす
ここから何を読む?
読み物リスト
TIPS
ECMA Internationalはスイスにある
13.2.4 Array Initializer
code:js
1,2,3 // こういうやつ
Array elements may be elided at the beginning, middle or end of the element list.
(英語) elide: 省略
[,,,]という感じで要素を省略してもOKという話
Elided array elements are not defined.
undefinedではないらしい
not definedな要素は列挙されるのか?→列挙の方法による
code:js
const ary = 0,1,,3
ary.forEach(v => console.log(v)) // 0, 1, 3
for (const v in ary) console.log(v) // 0, 1, 3
for (const v of ary) console.log(v) // 0, 1, undefined, 3
If an element is elided at the end of an array, that element does not contribute to the length of the Array.
末尾の省略された要素はArrayの長さにカウントされない
trailing commaのための仕様っぽい
code:js
0.length // 1
,0.length // 2
0,.length // 1
Arrayの要素として AssignmentExpressionが使える
code:js
a = 1; console.log(a) // => 1
13.2.4.1 Runtime Semantics: ArrayAccumulation
Arrayのlengthに値をセットする処理
$ 2^{32} - 1とは?
配列が保持できる値の最大数っぽい
以下に言及ありyebis0942.icon
https://tc39.es/ecma262/#array-index
https://tc39.es/ecma262/#sec-array-exotic-objects
13.2.4.2 Runtime Semantics: Evaluation
Arrayを初期化する処理
13.2.5 Object Initializer
An object initializer is an expression describing the initialization of an Object, written in a form resembling a literal.
object initializerはliteralではない説
Literalの定義: https://tc39.es/ecma262/#sec-primary-expression-literals
NullLiteral, BooleanLiteral, NumericLiteral, StringLiteral
Regular Expression Literalはliteralではないのか…?
というか文法定義ではObjectLiteralという名前が付いているが…?
ここで我々は考えるのをやめた
CoverInitializedNameが使われているObject Initializerとはどんなもの?
以下のような文法が合法になりそうだが、実際は文法エラーになる
code:js
({ a = 1 }) // Syntax Error
→NOTE 3に補足があった。カバー文法のためにここではゆるい文法規則として定義されていて、Static Semantics: Early Errorsのなかで追加的な文法チェックが行われる。(これによってconst { a = 1 } = objectのような分割代入記法が定義できるようになっている)
次回
引き続き見ていくかも
https://tc39.es/ecma262/#sec-object-initializer-static-semantics-early-errors
というか11 ECMAScript Language: Source Textから読んでいってもいいかも説
10 Ordinary and Exotic Objects Behavioursは読むとしても見出しぐらいで…
11からで!