ECMAScript仕様輪読会 #58
前回: ECMAScript仕様輪読会 #57
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
時事ネタ
https://github.com/tc39/agendas
https://github.com/tc39/notes
https://github.com/tc39/proposals
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
Go / TSを書いて暮らしてます
iwatsurut
とくに、イベントもなく過ごしています。
js の話題ではないが、今週末 Kansai.go に参加します。
前回の復習していて、generator のない、es5.1 をちょろっと見てみたらやっぱり全然違った。
tomato3713
https://twitter.com/tomato3713
Go/TS/Perlを書いてます。
以前会話していた社内でGoのProposalを読む会の2回目を最近しました
reflect: add Type.CanSeq/CanSeq2 and Value.Seq/Seq2 methods · Issue #66056 · golang/go · GitHub を眺めました
Jboy
Twitter: https://x.com/JBOY83062526?ref_src=twsrc^google|twcamp^serp|twgr^author
Github: https://github.com/sakurakotubaki
普段は、Flutter, Deno書いてます。 Supabase, Firebaseでサーバレスな開発してます。
今回は初参加です笑
前回のあらすじ
FunctionDeclarationInstantiation
関数の中身を実行するのに必要なものを揃える部分を読んでいた
今回の範囲
https://tc39.es/ecma262/#sec-functiondeclarationinstantiation のStep 25, 26から
25. function(a, a) みたいなときの処理
7.4.13 CreateListIteratorRecord
https://tc39.es/ecma262/#sec-createlistiteratorRecord
Iterator Record { NextMethod: %GeneratorFunction.prototype.prototype.next% }.
27.5.1.2 %GeneratorPrototype%.next ( value )
https://tc39.es/ecma262/#sec-generator.prototype.next
1. Return ? GeneratorResume
https://tc39.es/ecma262/#sec-iterator-interface
https://developer.mozilla.org/ja/docs/Web/JavaScript/Guide/Iterators_and_generators#反復可能オブジェクト
code:js
const end = 10;
let count = 0;
const it = {
next(i) {
if (count < end) {
count += i;
return {
value: count,
done: false,
};
}
return { done: true };
},
};
/*
let result = {};
while (!result.done) {
result = it.next(2);
if (result.done) {
break;
}
console.log(result.value);
}
*/
const obj = {
Symbol.iterator: () => it,
};
// NaN
for (const val of obj) {
console.log(val);
}
tomato3713.icon https://developer.mozilla.org/ja/docs/Web/JavaScript/Guide/Iterators_and_generators#高度なジェネレーター
メモ: next() の最初の呼び出しに渡された値は常に無視されます。
まだでてきていなかったと思うけど、仕様のどこかに書かれているんだろうか
syumai.icon Generator側の仕様なんじゃないですかね
https://tc39.es/ecma262/#table-iterator-interface-optional-properties
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Generator/return
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw
https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Statements/for...of
for-of を break などで途中中断すると return() が呼ばれると書いてある
throw() がいつ呼ばれるかわからない
Iterator Records は next method を持っていてIterator interface を満たせば良いものではない
for-of などの時にだけ作られる
ループ中に外からいじられないようにIterator Recordsを作ってる?