Twitter hashtag: #esspec
YouTube:
自己紹介 (近況報告)
syumai
GoとTSやってます
connect-webでおもちゃが出来ました
Jun Yasumura / harupiyo Jun Yasumura.icon
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
前回話していた esspec のメモ的なものにいくつか追記したり
前回ちょっと疑問になっていた件が解決した
10月から業務委託で働き始めることが決まった
aumyさんがいらっしゃった
noyannoyan.icon
前回は疲労で寝てました
GitHub Actionsでactions/cacheを使用せずCache APIを使用して高速化するやり方をまなんだ
モノレポ環境で極度に並列化されたCIで役に立つはず
hashfilesでのglob patternが仕様とことなるものを発見したりした
Factorioがおもしろい(Splatoonのかわり)
from tarsさん
前回ちょっと話題になっていた、Runtime Semantics: StringNumericValue の定義に StrDecimalLiteral ::: + StrUnsignedDecimalLiteral のケースが抜けてるのでは?問題、わかりました! (matrix の tc39 beginners チャンネルで教えてもらった)
chain production ルールによって暗黙的に以下の定義が含まれるようです。👍
StrDecimalLiteral ::: + StrUnsignedDecimalLiteral
1. Return StringNumericValue of StrUnsignedDecimalLiteral
chain production に関しては以下に個人的なメモを書いたので貼っておきます!
TL;DR: syntax-directed operations で「この生成規則のケースなくない?」みたいなときは chain production ルールを疑うと良い
ToInt16
ToInt32 とほぼ同じ
ToUInt16
ToUInt32とほぼ同じ
ToUint8Clamp
2^8 の読み方
1. Let number be ? ToNumber(argument).
2. If number is NaN, return +0𝔽.
3. If ℝ(number) ≤ 0, return +0𝔽.
4. If ℝ(number) ≥ 255, return 255𝔽.
5. Let f be floor(ℝ(number)).
6. If f + 0.5 < ℝ(number), return 𝔽(f + 1).
7. If ℝ(number) < f + 0.5, return 𝔽(f).
8. If f is odd, return 𝔽(f + 1).
9. Return 𝔽(f).
code:js
// 4
const n = 254.9
// 5
const f = 254
// 6
(f + 0.5) < n // 254.5 < 254.9 => true => 255
// 4
const n = 254.1
// 5
const f = 254
// 6
(f + 0.5) < n // 254.5 < 254.1 => false
// 7
n < (f + 0.5) // 254.1 < 254.5 => true => 254
// 4
const n = 254.5
// 5
const f = 254
// 6 => +0.5 が浮動小数点数ではない!
(f + 0.5) < n // 254.5 < 254.5 => false
// 7
n < (f + 0.5) // 254.5 < 254.5 => false
// 8
f % 2 === 1 // 254 % 2 (0) false
// 9
f // => 254
// 4
const n = 253.5
// 5
const f = 253
// 6 => +0.5 が浮動小数点数ではない!
(f + 0.5) < n // 253.5 < 253.5 => false
// 7
n < (f + 0.5) // 253.5 < 253.5 => false
// 8
f % 2 === 1 // 253 % 2 (1) true => f + 1 => 254
丸めの方法
ToUint8Clamp
"round half to even" tie-breaking
Math.round
"round half up" tie-breaking
小数点部が0.5であれば、偶数に丸める(Round half to even)の字義通りなのか
なるほど~tars0x9752.icon
ToUInt8Clamp が使われているのは UInt8ClampedArray のみ
わりと新しい仕様っぽい
ToBigInt
ToPrimitive の結果が...
null | undfined なら TypeError
Boolean なら true で 1n、false で 0n
1n は BigInt の 1
BigInt ならそのまま返す
Number なら TypeError
String なら StringToBigInt (もしその結果 undefined なら TypeError)
Symbol なら TypeError
ToBigIntはNumberが渡ってくるとthrowする
BigInt()関数は、Numberが渡ってきたら別のNumberToBigIntと言うabstract operationを適用する
そのため、ToBigIntに直接Numberが渡ってくることはない(はず)
StringToBigInt
StringIntegerLiteral な ParseNode に MV を適用してそれを BigInt にしてリターン
StringIntegerLiteral
[~Sep] は Sepパターンを除くの意味っぽい
Sep はおそらくセパレーター(_)
多分行き着く先はここ 12.9.3.3 Static Semantics: NumericValue
Static Semantics: MV
↑ MV のやつ、ありました
MV の semantics どこ問題判明した
ToBigInt64
ToBigUint64
ToString
テーブル参照
結局 ToPrimitive でほとんど string になりそう (ordinary object のばあい)
次回: ToObject から!