ECMAScript仕様輪読会 #16
前回: ECMAScript仕様輪読会 #15
Scrapboxの招待リンク: https://scrapbox.io/projects/esspec/invitations/85b96c9fa718ce5185e307196ed8fb53
connpass: https://esspec.connpass.com/
Discord: https://discord.gg/59S3y6weQj
Twitter hashtag: #esspec
自己紹介 (近況報告)
syumai
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
GoとTSやってます
仕事では最近はdraw.ioをやってます
最近詰将棋をやってます
IPAの募集が始まったので申し込みました
Jun Yasumura / harupiyo Jun Yasumura.icon
はじめてIssue(要望)もらいました https://github.com/harupiyo/time-calculator/issues/1
noyannoyan.icon
最近はセキュリティを学んでいます
おーみーaumy.icon
Twitter: aumy_f GitHub: aumyf
前回は腹痛を起こして実質休みでした
GraphQL Language ServiceへのPRを再開
https://github.com/graphql/graphiql/pull/2391
静的型チェック・型推論の実装
https://github.com/AumyF/mini_camlish_typed
WebAssemblyへのコンパイラを書きたい
ガベージコレクション…
tars0x9752 (たーず / naoki aoyama)
NixOS を入れた.
1週間くらい旅行にいってきた. しばらくPCから離れた生活をした.
yebis0942yebis0942.icon
ISUCON完
ベンチマーカーの公開が楽しみ
最近びっくりしたこと
gitにはユニットテストがないっぽい
https://github.com/git/git/tree/master/t
シェルスクリプトでコマンドレベルのE2Eテストが大量に書かれてるっぽい
もしかしてGitHub-flavored markdownの最近の挙動って仕様化されてないし、HTML化するライブラリも公開されてない?
これではないですか?
https://github.github.com/gfm/
👀
HTML化は各種ライブラリあるはず
GitHub-Flavored markdownのscrapboxが欲しい(欲しくないですか)
↓最近のVue/Nuxt事情全然知らなかった。進化してるんですね〜
Nozomu Ikuta NozomuIkuta.icon
Twitter: https://twitter.com/NozomuIkuta
GitHub: https://github.com/NozomuIkuta
Nuxt Feed moduleのNuxt 3化のPRを出したところ、Nuxt 3に必要な機能がまだなくて止まってます
Scrapboxのsyntax難しい
Zigってなんで流行ってる?
unjs
https://github.com/unjs
https://github.com/oven-sh/bun
バンなるほどyebis0942.icon
Zig + JavaScriptCoreの高速なJSエンジン
Carbon
https://www.publickey1.jp/blog/22/ccarbon_languagegooglec.html
C++倒すぞ的なやつらしい(?)
前回のあらすじ
super.fooという参照をしたときの動きを深掘りしていた
メモ: super.fooみたいな参照のreference recordを作るのはMakeSuperPropertyReferenceかな…?
https://tc39.es/ecma262/#sec-makesuperpropertyreference
superを経由してprivate fieldを参照することはできないっぽい
---
20:55まで休憩
今回の範囲
6.2.4 The Reference Record Specification Type の 6.2.4.6 PutValue の 6. Else からです。
https://tc39.es/ecma262/
6.2.4.6 PutValue ( V, W )
base.SetMutableBinding
SetMutableBindingの定義は?
Table 19: Abstract Methods of Environment Recordsに概略がありそう
読んでもよくわからないのでここではスキップ
yebis0942.icon9.1.1の見出しを見た感じだとEnviroment Recordは何種類もあって、それぞれに異なるSetMutableBindingを持っていたりするらしい
GetValueと同じ内容のNOTEがある
6.2.4.7 GetThisValue ( V )
Vを受け取ってECMAScript language valueを返す
Assert: IsPropertyReference(V) is true.
なぜこういうAssertができるのか?
次の6.2.4.8で議論しました
6.2.4.8 InitializeReferencedBinding ( V, W )
Assertについて
PutValueとかのAssertは、「stepを適用していけば当然こうなる」ということを念のために書いておくという性質だったように思うが
ここのalgorithmでは違う使われ方をしてそう
「こういう性質の値が引数として渡されることを期待する」という表明をしているのでは
つまり、Assertには「algorithm上は当然こういう結果になる」と「こういう使われ方を期待してます」という二通りの用途がありそう
Environment Recordが登場したので途中でスキップ
6.2.4.9 MakePrivateReference ( baseValue, privateIdentifier )
同じくEnvironment Recordが登場したのでスキップ
Environment Recordを把握したら再読したい項目
PutValue, InitializeReferencedBinding, MakePrivateReference
Enviroment Record
The Property Descriptor Specification Type
Object property attributes の操作と具体化?具象化?のためのもの
Property Descriptor Record の attributes
https://tc39.es/ecma262/#sec-property-attributes
schema name は "PropertyDescriptor"
分類
Data Property Descriptorは次を使う/持つ: [[Value]] or [[Writable]]
Accessor Property Descriptorは次を使う/持つ: [[Get]] or [[Set]]
共通: [[Enumerable]] and [[Configurable]]
data と accessor の両方の attribute を同時に持つことはできないが, どちらでもない場合がある
data と accessor のどちらでもない場合: Generic Property Descriptor
fully populated Property Descriptor
[[Enumerable]] and [[Configurable]] プラス, data なら [[Value]] and [[Writable]], accessor なら [[Get]] and [[Set]] を持つもの
The following abstract operations are used in this specification to operate upon Property Descriptor values:
これは引数の型を制約していると解釈するべき?
ではなさそう
Reference Valueの箇所にも同様の記述があったが、一部のabs opには引数の型をチェックするstepがある
そもそもdescriptorとは?
コンピュータ関係の用語では「データがどのように保存されているかを示すデータ」という意味で使われる
property descriptor
property の保存とかに関する性質とかメタデータみたいな
実際のJSの世界では defineProperty() とか getOwnPropertyDescriptor() とか
ところでRecordのfieldは後から追加・削除できるのだろうか?
仕様には明記されてなさそう
おそらくfieldは不変なのではないか
by syumai.icon https://discord.com/channels/938061684872990741/938061685321777235/1003992288596336640
https://tc39.es/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots-defineownproperty-p-desc
↑を追っていくとわかりそう
IsAccessorDescriptor ( Desc )
Desc !== undefied && (Desc has [[Get]] || Desc has [[Set]])
IsDataDescriptor ( Desc )
Desc !== undefied && (Desc has [[Value]] || Desc has [[Writable]])
IsGenericDescriptor ( Desc )
Desc !== undefied && !IsAccessorDescriptor(Desc) && !IsDataDescriptor(Desc)
FromPropertyDescriptor ( Desc )
おそらくJSのgetOwnPropertyDescriptor()とかのために, 内部のPropertyDescriptorを実際のJSのオブジェクトとして変換するために使われそう(次に出てくる ToPropertyDescriptor はその逆っぽい)
2. Let obj be OrdinaryObjectCreate(%Object.prototype%).
%Object.prototype%とは
intrinsic objectのようだが…
well-known intrinsic objectには含まれていないし、他の箇所にも定義はなさそう
たぶん「intrinsic objectである%Object%のprototypeプロパティ」という意味
OrdinaryObjectCreate( proto [ , additionalInternalSlotsList ] )
新しい ordinary object を作成するために使う
beyond [[Prototype]] and [[Extensible]]
おそらく「[[Prototype]]と[[Extensible]]に加えて」という意味
ordinary objectが必ず持っているinternal slotsは?
[[Prototype]]と[[Extensible]]らしい
参照: Ordinary Object Internal Methods and Internal Slots
All ordinary objects have an internal slot called [[Prototype]].
Every ordinary object has a Boolean-valued [[Extensible]] internal slot...
MakeBasicObject()
ordinary objectの生成でもexotic objectの生成でもこの抽象操作が使われる
CreateDataPropertyOrThrow(obj, "value", Desc.[[Value]]).
この"value"は何者?
太字セリフ体なのでECMAScript Language Value
ECMAScriptの"value"という文字列
JSの世界で使うための値なのでLanguage Valueを使っているのだと思われる
次回に続く
ECMAScript仕様輪読会 #17