ECMAScript仕様輪読会 #41
前回: ECMAScript仕様輪読会 #40
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
自己紹介 (近況報告)
syumai syumai.icon
Twitter: https://twitter.com/__syumai GitHub: https://github.com/syumai
こう言うのを始めました
Asakusa.go #1
初回来月13日(金)です
満員御礼であったyebis0942.icon
tars0x9752 (たーず / naoki aoyama) tars0x9752.icon
特になし
Nodejs 16 EOL
https://node.green/
yebis0942 (えびす) yebis0942.icon
Go, Reactを書いて暮らしています
最近はFetchの仕様書を読んだりしていました
https://fetch.spec.whatwg.org/#request-class
If input is a string, then:
と書きつつ、実装では暗黙的にtoStringしてそう
https://fetch.spec.whatwg.org/#fetch-method
If response is a network error, then reject p with a TypeError and abort these steps.
ネットワークエラーでもTypeErrorが投げられる。マジか
TypeError is used to indicate an unsuccessful operation when none of the other NativeError objects are an appropriate indication of the failure cause.
https://tc39.es/ecma262/#sec-native-error-types-used-in-this-standard-typeerror
antisatori
急に使ってみたくなって初めてneovimの設定しました
nvchad 使ったら見た目だけvscodeみたいになりましたが難しくてすぐ辞めそう
tars0x9752.icon nvchad 知らなかった
syumai > すごいVimの動画です
https://www.youtube.com/watch?v=cWvAhmfZJZg
tars0x9752.icon vimmer ではないけど git のコミットメッセージ書くときだけ neovim 使ってます
yebis0942.icon 最近テキストオブジェクトの使い方を教えてもらって大感動しました
https://qiita.com/kasei-san/items/143af11bb2559cf0e540
前回のあらすじ
今回の範囲
読み物リスト
11.2.3 Non-ECMAScript Functions
関数 exotic object
native codeで定義された関数っぽい
12 ECMAScript Language: Lexical Grammar
multiple goal symbolの列挙
これは例示ではなくて仕様の記述っぽい
table:multiple goal symbols
Goal Symbol 使われる文脈
InputElementHashbangOrRegExp Script or Moduleの最初
InputElementRegExpOrTemplateTail RegularExpressionLiteral, TemplateMiddle, TemplateTailが許される場所
InputElementRegExp RegularExpressionLiteralが許されるが、TemplateMiddleもTemplateTailも許されない場所
InputElementDiv 他のすべての文脈
これは何のためのルールなのか?
たぶん曖昧な文法を解消するためのルール
具体的には…
InputElementHashbangOrRegExp: ソースコードの先頭だけでHashbangを受け付けるようにするルール
その他は/を割り算の記号と正規表現の記号のどちらと判定するかで曖昧性が生じないようにするルール
「先頭に割られるものがなければ正規表現」みたいな感じっぽい
code:hashbang.js
// huga (これがInputElementHashbangOrRegExpになる)
#!/usr/bin/env node (ここはInputElementDivとしてパースされるのでsyntax error)
コメント
/の扱いややこしいですね
ScalaにはXMLリテラルという機能があってパースが大変そう
https://www.ne.jp/asahi/hishidama/home/tech/scala/xml.html
かつてECMAScript for XMLという仕様があった(廃止済み)
Proposal: ESX as core JS feature
table:syntax
Component InputElementDiv InputElementRegExp InputElementRegExpOrTemplateTail InputElementTemplateTail InputElementHashbangOrRegExp
WhiteSpace ✓ ✓ ✓ ✓ ✓
LineTerminator ✓ ✓ ✓ ✓ ✓
Comment ✓ ✓ ✓ ✓ ✓
CommonToken ✓ ✓ ✓ ✓ ✓
DivPunctuator ✓ ✓
RightBracePunctuator ✓ ✓
RegularExpressionLiteral ✓ ✓ ✓
TemplateSubstitutionTail ✓ ✓
HashbangComment ✓
12.1 Unicode Format-Control Characters, 12.2 White Space
Unicode format-control characters: テキストの向きを制御したりできるunicode文字
U+200C (ZERO WIDTH NON-JOINER) and U+200D (ZERO WIDTH JOINER)
Identifierには使える(ただし先頭に登場してはいけない)
code:js
eval("let \u200c") // Uncaught SyntaxError: illegal character U+200C
eval("let a\u200c") // OK
eval("let a\u200c\u200c") // OK
文字間を分離するための文字
https://ja.wikipedia.org/wiki/ゼロ幅非接合子
文字をくっつけるための文字
https://ja.wikipedia.org/wiki/ゼロ幅接合子
絵文字とかにも使える
ZERO WIDTH NO-BREAK SPACE
https://unicode-explorer.com/c/FEFF
copy("\ufeff")
RIGHT-TO-LEFT MARK
https://en.wikipedia.org/wiki/Right-to-left_mark
Space_Separator
https://www.compart.com/en/unicode/category/Zs
https://www.compart.com/en/unicode/U+1680