2024-06 の TC39 meeting
まとめ
Agenda: https://github.com/tc39/agendas/blob/main/2024/06.md
速報: https://github.com/babel/proposals/issues/89
Note: https://github.com/tc39/notes/blob/main/meetings/2024-06
決まったこと
Web compatibility issues / Needs Consensus PRs
ECMA-402 PR #877: Specify time zone IDs to reduce divergence between engines (slides) | Justin Grant
タイムゾーンについてのデータは IANA Time Zone Database (TZDB) と、それをベースにした The Unicode Common Locale Data Repository (CLDR) がある。
CLDR を使うのは必須ではないが V8 と JavaScriptCore は使っており、それによって SpiderMonkey とで古いタイムゾーン ID をリネームされた新しいタイムゾーン ID に変換するときに差異が発生していた。
https://gyazo.com/23be9b843b347214837bb34de10e5f08
この変換アルゴリズムを ECMA-402 Intl に記述する Normative Change が承認された。SpiderMonkey が修正を迫られることとなる。
Stage 4 (ES2025)
N/A
Stage 3
eval() changes for trusted types update (description) | Nicolò Ribaudo
前回の会議で new Function の場合 HostEnsureCanCompileStrings に全文字列情報をを渡さないという決断がされていたが、Function#toString ですでにユーザーに公開されている情報でありそれでは困るということがわかった。その部分のみリバートされた。
Avoid second pass/buffer in base64 setFromBase64/setFromHex methods (issue, PR) | Kevin Gibbons
Uint8Array#setFrom{Base64, Hex} で、渡された文字列が invalid だった場合 Uint8Array に変更を加えないようになっていたが、パフォーマンスのため先頭の valid な文字列の間は Uint8Array に変更を加え、その後で invalid な部分に到達したら SyntaxError を投げるようにする Normative Change。承認された。
例外が投げられたときにどこまで書き込まれたのかがわからないの難点。
It would be nice for SyntaxErrors to have a standardized .offset property which told you where the error was, not just for this but also JSON.parse etc. But that's unlikely to be in this proposal.
https://github.com/tc39/proposal-arraybuffer-base64/pull/58
Option to omit padding in toBase64 (issue, PR) | Kevin Gibbons
Uint8Array#toBase64 で末尾の = を出力しない omitPadding オプションを追加する Normative Change。承認された。
Intl.DurationFormat Stage 3 update and normative PRs (slides) | Ben Allen
hours, minutes, seconds に大きい値を渡したときにカンマ区切りされないようにする小さな Normative Change があった。
https://gyazo.com/24e53cd9ef4a1089a2ac0f692beedae1
https://github.com/tc39/proposal-intl-duration-format/issues/192#issuecomment-2057061904
Temporal Stage 3 update and scope reduction (slides) | Philip Chimento
まず2つの Normative Change があった。
1つ目は PlainDateTime で月末で Duration がおかしくなるエッジケースの対応。
code: js
pdt1 = Temporal.PlainDateTime.from '2023-02-28T03:00:00')
pdt2 = Temporal.PlainDateTime.from '2023-04-01T02:00:00')
dur = pdt1.until(pdt2, { largestUnit: 'year' })
// ACTUAL: { months: 1, hours: 23 }
// EXPECTED: 1 months: 1, days: 3, hours: 23 }
2つ目は U+2212 をマイナスとして扱わなくする対応。
code: js
const dtf = new Intl. DateTimeFormat("pt", {
dateStyle: "short",
timeStyle: "full",
timeZone: "\u{2212}01:00",
});
dtf.format(new Date("2024-01-01T00:00Z"))
// Current: "31/12/2023, 23:00:00 GMT-01:00"
// Proposed: RangeError; timeZone would need to be "-01:00"
ここから本題。Temporal が大きい仕様となってしまい、すべてを一度に実装することになると(長期的には最適化されていくだろうが)短期的にリソースに制限のあるデバイスに問題が発生してしまう。そこで一部仕様を削減し、削減された仕様は v2 として延期する話があった。
https://gyazo.com/7f1893352b7d53b6600396cba7962233
https://gyazo.com/fad98cfd3a374667105e4eb6853b351d
このあたりについては Saji さんの記事が詳しい。
https://zenn.dev/cybozu_frontend/articles/temporal-reduces-scope
subtract と since メソッドについては承認が得られなかったが他は概ね削減されそう。削減される中身については size-suggestion タグのついた issues を見れば良さそう。
Continuation from previous meeting: Explicit Resource Management Normative Updates and Needs Consensus PRs (slides, PRs) | Ron Buckton
前回の続き。Normative Change が承認された。
Promise.try for stage 3 (tests) | Jordan Harband
Stage 3 になった。
Stage 2.7
ShadowRealm status FYI (slide) | Philip Chimento
HTML 仕様との統合が進められている。
RegExp.escape question, and for stage 2.7? | Jordan Harband
Stage 2.7 になった。
Deferred import evaluation for Stage 2.7 (slides) | Nicolò Ribaudo
Stage 2.7 になった。
joint iteration for Stage 2.7 (slides) | Michael Ficarra
Stage 2.7 になった。
デモページができた。
https://tc39.es/proposal-joint-iteration/demo/
Atomics.pause for stage 2 or 2.7 | Shu-yu Guo
Atomics.microwait が Atomics.pause に変更された。Stage 2.7 になった。
Stage 2
Async iterators update (slides) | Kevin Gibbons
将来的に順序を保持しない並列処理可能な API も入れたいという話が出た(今回はスコープ外)。
Error.isError for stage 2 | Jordan Harband
Stage 2 になった。
ESM Phase Imports for stage 2 (slides) | Guy Bedford
Stage 2 になった。
Discard Bindings update or stage 2 (slides, spec) | Ron Buckton
カバー文法の問題で _ にする提案があったが一旦保留。Stage 2 になった。
Stage 1
iterator sequencing for Stage 2 (slides) | Michael Ficarra
無限の Iteretor を扱うのを辞めた。Iterator.concat を用意し、0個以上の引数をいれる。違う名前にしたい話が出ている。
Intl.MessageFormat Stage 1 open question involving error handling design patterns (slides) | Shane F. Carr
Unicode MessageFormat 2.0 でエラーハンドリングについての話が出ており、それを ECMAScript 側でどうしようか議論されている。MF2 側で Message Errors と Resolution Errors があり、それを ECMAScript でハンドリングするいくつかの提案があった。
Shared struct discussion around methods (slides) | Shu-yu Guo
Shared Struct のメソッド周りの仕様が複雑になってしまっているので、このあたりをどうしようか議論されている。
個人的にはメソッドを実装できるようにすると Worker に空の Shared Struct を使って関数のやり取りをする悪いハックが出てくるんじゃないかという懸念がある……。
Decimal for stage 2 (slides) | Jesse Alama
仕様テキストを再度確認する必要があるとして Stage 2 にはならなかった。Intl 周りでの作業が必要。
Stage 0
N/A
Withdrown
N/A
その他
Source maps progress update (slides) | Jonathan Kuperman and Agata Belkius
Source maps を作るジェネレーターとそれをつかうコンシューマで使う test suite を作っている。コンシューマであるFirefox の DevTools に test suite が入った。Chrome にも間もなく入る。
Nova JavaScript Engine—Exploring a data-oriented engine design (slides) | Aapo Alasuutari
半分趣味で作っている Rust 製の JS エンジンの紹介(たまたま現地にいた学生による発表)。
https://github.com/trynova/nova
Cancellation: Room for improvement (slides) | Daniel Ehrenberg and Ron Buckton
AbortController/AbortSignal が有用なので ECMAScript に持ってきたい話。WHATWG と TC39 で議論する。EventTarget を継承している関係もあって難しそう。
Smart units progress update (slides) | Ben Allen
Intl.NumberFormat で単位の変換(メートルからヤードポンドなど)をする提案。興味がある方はチャンピオンに DM してとのこと。
Scrub of less active TC39 proposals | Daniel Ehrenberg
アクティブじゃない提案の棚卸し。
Stage 3 Legacy RegExp features
実装者的に特に興味がないが、パッチが来たら入れるという状況にある
Stage 3 JSON Modules
Stage 3 Import Attributes の実装待ちの状態
V8 から assert キーワードの実装が取り除かれていることが共有された
Stage 3 Float16Array
各エンジンが実装中
Stage 3 Decorators & Decorator Metadata
test262 がほぼできている状態
実装待ち
Stage 3 JSON.parse source text access
test262 がまだない
Stage 3 Sync Iterator Helpers
Web 互換性のための仕様変更に対応中
Stage 3 Explicit Resource Management
各エンジンが実装中
テストも実装中
Stage 3 Source Phase Imports
V8 で実装中
今のところ test262 でシンタックスに対するテストができなかったが、これを機会にいれるかもしれない
Stage 2 Function.sent meta-property
今後 Function Decorators に合わせて進めていくかも
https://github.com/tc39/proposal-function-and-object-literal-element-decorators
Stage 2 Throw expressions
シンタックスで揉めている
Stage 2 Function implementation hiding
モチベーションを再定義して進めていくかも
Algorithms for Signals (slides) | Daniel Ehrenberg
Signal の具体的な API の話。各ライブラリなどを巻き込んで実証実験する。
総括
今回一番大きい話題としてはやはり Temporal の API 削減の話になるかなと思う。早いことエンジンに実装されてほしいと切に願っている。
#ECMAScript