Twitter hashtag: #esspec
https://youtu.be/elnLi3c80VI
自己紹介 (近況報告)
syumai
GoとTSやってます
Cloudflare Workers
Jun Yasumura / harupiyo Jun Yasumura.icon
HTML5.0仕様書を読んだ経験あり
noyannoyan.icon
Firefoxにバグ報告?をしたら思ったより色々動いている
試用期間が終わるので、ミーティングがこわい
おーみーaumy.icon
ThinkPad X13 Gen 3買った
毎日発送状況確認してる
graphql-language-serviceに発射したpull requestのやる気が出ない
tars0x9752 (たーず / naoki aoyama)
有休消化
普段 fish だけど bash + ble.sh を試したり
fig.io ちょっときになるかも
solidjs ちょっと触ってみたり
yebis0942yebis0942.icon
最近はBubble Teaを触ってます
Go製のTUIフレームワーク
Reactっぽい書き味で雑にTUIアプリを書けて楽しい
QRコードのエンコード処理とかを抜くと60行ぐらい
Nozomu Ikuta NozomuIkuta.icon
Vue Fes Japan Online 2022 CFP 募集中です!(~6/30)
数回欠席して追いつかるか不安
前回のあらすじ
ordinary object
essential internal methodを持っている
exotic object
↑が上書きされてる
不変条件的な意味っぽい
日本語訳は謎
MDNでは"invariants"を不変条件と訳している
---
今回の範囲
6.1.7.3 Invariants of the Essential Internal Methods の [[GetOwnProperty]] ( P ) から
6.1.7.3 Invariants of the Essential Internal Methods
[[GetOwnProperty]](P)
この引数のPってなんだっけ
abs opの定義上はproperty key
文章中ではproperty keyが持つpropertyと同一視されていることがよくある
non-configurable
定義あったっけ
[[Configurable]] === falseであることらしい
Note 3: 三番目の不変条件の対偶の説明になっている
文章を読んだだけだとあまり頭に入ってこないかも…
[[DefineOwnProperty]] ( P, Desc )
引き続き読みにくい感ある
abs opのアルゴリズムそのものには触れず、abs opが守るべきルールだけを説明しているからか
[[HasProperty]] (P)
[[Get]] (P, Receiver)
"with value V"はどこに掛かっているのか
"a data property with value V"という修飾関係と解釈するとよさそう
2番目の不変条件は本当に成立するのか?
If P was previously observed as a non-configurable, non-writable own data property of the target with value V, then [[Get]] must return the SameValue as V. (太字は引用者による)
data propertyという制約を外すと成立しなくなる
accessor propertyはアクセス時にランダムな値を返したりできるので、値Vが変わることがありえる
internal methodとproperty attributeの区別
[[Get]] attribute
この[[Get]]はproperty attribute
表記が同じなのがややこしい
the [[Get]] operation
こっちはabstract operation
[[Get]] must return
これはreturnとあるからabstract operationっぽい
[[Set]] (P, V, Receiver)
code:js
const a = {};
Object.defineProperty(a, "p" { get: () => {}, set: () => {}});
[[Delete]] (P)
[[OwnPropertyKeys]]
If the target is non-extensible, the returned List must contain only the keys of all own properties of the target that are observable using [[GetOwnProperty]].
extensibleならGetOwnPropertyで観測可能でないプロパティキーを返してもよい?
たしかにextensibleなら制約されないのは腑に落ちない気がしてきました…yebis0942.icon
[[GetOwnProperty]]で観測可能でないプロパティが[[OwnPropertyKeys]]に登場するケースとは?
ordinary objectでは起こり得ないが、exotic objectで[[GetOwnProperty]]を差し替えたときには起こり得るので禁止しているっぽい
Proxyを使ってinvariantsに違反するオブジェクトを作ってみた例yebis0942.icon
違反した瞬間にTypeErrorが出るらしい
code:js
const ordinal = { x: 1 };
Object.preventExtensions(ordinal);
const exotic = new Proxy(ordinal, {
// OwnPropertyKeysを常に空Listを返すように改変している(はず)
ownKeys: function () {
return [];
},
});
console.log(exotic.x); // => 1
console.log(Object.getOwnPropertyNames(ordinal)); // => 'x' console.log(Object.getOwnPropertyNames(exotic)); // => TypeError: 'ownKeys' on proxy: trap result did not include 'x'
6.1.7.4 Well-Known Intrinsic Objects
%name%: 今のrealmに紐付いているnameというintrincis objectを指す
そもそもrealmとは…?
intrinsic objectの集合
ECMAScriptのグローバル環境
そのグローバル環境にロードされたECMAScript
その他の状態とかリソースとか
ECMAScriptの実行環境らしい
Realm Record Fieldsを見ると[[GlobalEnv]]とかがあるので、realmが違うとグローバル変数とかが共有されないっぽい
ユーザーがrealmを定義できるAPIを作ろうという提案
Stage3なので導入は確実そう
これまではiframeとかnodeのvmとかで隔離環境を作っていた
Well-Known Intrinsic Objects
グローバルオブジェクト一覧的な雰囲気がある
AtomicsとかDataVieweとかFinalizationRegistryとか、未知のものがある
builtin object == intricis objectsなのか?
Additional entries in Table 94
ブラウザの場合にはちょっとだけ関数が追加される
(英語) intrinsic: とりあえずそのまま読む
intrinsic object: 固有オブジェクト?
(英語) realm: とりあえずそのまま読む
(英語) determination of X: Xの特定方法
6.2 ECMAScript Specification Types
仕様の記述のために使われる値の型
この型の値をECMAScriptのプロバティや変数として観測することはできない
どんな型があるのか
Reference, List, Completion Record, Property Descriptor, Environment Record, Abstract Closure, Data Block.
(英語) artefacts: artifactの異綴
6.2.1 The List and Record Specification Types
いわゆるリストとか配列と呼ばれるもの
アクセス方法: arguments[2] == argumentsというリストの3番目の要素
リテラル: « 1, 2 » == [1, 2]的な意味
« »: 空リスト
« »←「ギュメ」って読むらしい。guillemet
データの集約を表現する
1つ以上の名前付きフィールドからなる
リテラル: { [[Field1]]: 42, [[Field2]]: false, [[Field3]]: empty }
アクセス方法: R.[[Field2]]
フィールドの名前の順番は意味を持たない
明記されていないフィールドはないものとする
スキーマが定義されていることがある
フィールドの組み合わせを定めるもの
PropertyDescriptor { [[Value]]: 42, [[Writable]]: false, [[Configurable]]: true }のように使われる
ここではPropertyDescriptorがスキーマ
↑このあたりの説明って個別ページに移したほうがいいかもですねー。おまかせしますyebis0942.icon
aumy.icon一定程度まとまった段階でコピペですかね
たしかにyebis0942.icon
ECMAScriptのSetとは違う
そっちを言うときは Set objects と言う
unioned, intersected, subtracted: 和, 積, 差
subtractのみオペランドの順番によって結果が変わる
次回に持ち越し