ときどきの雑記帖 RE* (新南口)
七夕の国
中吊り広告
7月2日(土)から7月6日(水)の期間、
— アニメ「メイドインアビス」公式 (@miabyss_anime) July 1, 2022
東京メトロ有楽町線・副都心線の一部車両で、
「メイドインアビス 烈日の黄金郷」の中づりジャックを展開!
※駅係員へのお問合せはご遠慮ください。https://t.co/yPDAh0HxcO#miabyss pic.twitter.com/rJq75Q3ToQ
あれ? わしがこれを目撃したの7/1だったんだが…🤔
歴史群像
30周年だそうで。 創刊号から買っている(が手元に残っているのはごく一部)ので 遠い目になってしまいますねえ…
カナヘビ
野生のカナヘビ(たぶん)を目撃した。 何年ぶりだろう見たの。
セミ
今日の帰り道でセミの鳴き声を聞いた。 種類はわからん (アブラゼミっぽい鳴き声だったけど アブラゼミではないような)。
ミンミンゼミの初鳴は7/10~30頃(東京)。梅雨明けが早い=セミの初鳴が早いとは限らないようだ。
— にゃんこそば🌤データ可視化 (@ShinagawaJP) June 27, 2022
気象庁の担当者いわく・・・
「(セミの幼虫が育つ)地中は気温ほど大きな温度変化がない。植物は気温との関係が言いやすいが、動物は難しい」https://t.co/XoMSqMCgHA pic.twitter.com/7Doez2sOp2
Adding Modules to C in 10 Lines of Code
Cにもimportをという話(たぶん)で
Adding Modules to C in 10 Lines of Code [pdf] | Hacker News
https://nwcpp.org/talks/2022/modules_in_c.pdf
書いた(発表した)のは誰かと思えば
Adding Modules to C in 10 Lines of Code
by Walter Bright
April 2022
おや。
perse.y
「class 文のクラス名を指定するところに if 文が書けない」
— monochrome (@s_isshiki1969) July 2, 2022
というのは不具合なのか???
むしろそんなの書けていいの??
この辺↓の話だろうか?
- Bug #18890: parse.y: pattern label is newline-sensitive if it is dynamic - Ruby master - Ruby Issue Tracking System
- Bug #18884: parse.y: inconsistent parsing of “if” after “class” - Ruby master - Ruby Issue Tracking System
- Bug #18883: parse.y: trailing comma cannot coexist with star - Ruby master - Ruby Issue Tracking System
- Bug #18878: parse.y: Foo::Bar {} is inconsistently rejected - Ruby master - Ruby Issue Tracking System
立てつづけに出てきてちょっと驚いていたのだけど (なおツイートにあったissueはWON’T FIXとなった模様)。
今どきのLinux事情
なんとなく誰得でもなく話したくなったのでLinuxの話を社内でやった。特に質問もなくて寂しかったのでSpeakerDeckにアップロードしておく https://t.co/jbCf9XrYzV
— Tokida (@tokida) June 30, 2022
ツイートに対する反応にもあったけど
- Display TypeScript
- オブジェクト志向
がちょっと気になった😄
結構知らなかったことも多かったので 全体としては👍 👍
data-oriented
Principles of Data-Oriented Programming | Yehonathan Sharvit
This article is an excerpt from my book about Data-Oriented Programming.
Principle #1: Separate code from data
Principle #2: Represent data with generic data structures
Principle #3: Data is immutable
Principle #4: Separate data schema from data representation
for
for A in "$@";
— eban (@eban) July 2, 2022
じゃなくて
for A;
のように省略してもいい。#シェル芸
というのが気になったので(ry
とりあえずbash。
bash/parse.y
for_command: FOR WORD newline_list DO compound_list DONE
{
$$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD newline_list '{' compound_list '}'
{
$$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $5, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD ';' newline_list DO compound_list DONE
{
$$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD ';' newline_list '{' compound_list '}'
{
$$ = make_for_command ($2, add_string_to_list ("\"$@\"", (WORD_LIST *)NULL), $6, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD newline_list IN word_list list_terminator newline_list DO compound_list DONE
{
$$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD newline_list IN word_list list_terminator newline_list '{' compound_list '}'
{
$$ = make_for_command ($2, REVERSE_LIST ($5, WORD_LIST *), $9, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD newline_list IN list_terminator newline_list DO compound_list DONE
{
$$ = make_for_command ($2, (WORD_LIST *)NULL, $8, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
| FOR WORD newline_list IN list_terminator newline_list '{' compound_list '}'
{
$$ = make_for_command ($2, (WORD_LIST *)NULL, $8, word_lineno[word_top]);
if (word_top > 0) word_top--;
}
;
ふむ。
add_string_to_list ("\"$@\"", (WORD_LIST *)NULL)
しているあたりがそれっぽい。
次にopengroupの Shell Command Language をみる。
The for Loop
The for loop shall execute a sequence of commands for each member in a list of items. The for loop requires that the reserved words do and done be used to delimit the sequence of commands.
The format for the for loop is as follows:for name [ in [word ... ]] do compound-list done
First, the list of words following in shall be expanded to generate a list of items. Then, the variable name shall be set to each item, in turn, and the compound-list executed each time. If no items result from the expansion, the compound-list shall not be executed. Omitting:
in word...
shall be equivalent to:
in "$@"
なるほど。 Bourne Shellだとかは調べない😄
trash fire
Windows MSVCRTの malloc()実装はC言語史上最悪のクソだ。Linuxなら何も考えなくていいところを、Windowsではさまざまな小細工 (std::unordered_map を使わない、等) が必要にある。どうやらMS自身にとってもmallocは遅すぎたらしい。彼らは代替品の mimallocを開発している。https://t.co/QiCOMDXPOm
— 新山祐介 (Yusuke Shinyama) (@mootastic) July 3, 2022
元記事
The Windows malloc() Implementation Is A Trash Fire
のタイトルにあるTrash Fire
が気になったので調べてみると
trash fireの意味・使い方・読み方 | Weblio英和辞書
(slang) Something which is very poorly done; a mess.
ということらしい。
16進数
様々な言語の 16進数リテラル - Qiita という記事で、Cスタイルの16進リテラルの元祖を BCPLやBに求めようとしていた(そして見つけられなかった)のだけど、 実はCでも最初からあったわけではなかった(らしい)という。
Pre K&RのCそのものではないのだけど vegesm/c72: The first C compiler ported to x86 を見ると
c72/c03.c at master · vegesm/c72 にこんなコードがある。
void cc_printf(char *fmt, ...)
{
static char *s;
auto *adx, x, c, *i;
va_list arguments;
va_start(arguments, fmt);
loop:
while((c = *fmt++) != '%') {
if(c == '\0') {
va_end(arguments);
return;
}
putchar(c);
}
switch (c = *fmt++) {
case 'd': /* decimal */
case 'o': /* octal */
x = va_arg(arguments, int);
if(x < 0) {
x = -x;
if(x<0) { /* - infinity */
if(c=='o')
printf("100000");
else
printf("-32767");
goto loop;
}
putchar('-');
}
printn(x, c=='o' ? 8 : 10);
goto loop;
case 's': /* string */
x = va_arg(arguments, int);
s = x;
while(c = *s++) {
putchar(c);
}
goto loop;
case 'p':
s = va_arg(arguments, int*);
#ifdef WIN32
putchar('_');
#endif
c = namsiz;
while(c--)
if(*s)
putchar(*s++);
goto loop;
}
putchar('%');
fmt--;
goto loop;
}
p
が謎めいているけどそれはさておき
十進(d
)と八進(o
)はあっても
十六進(x
)はなし
(c72/c11.c at master · vegesm/c72
にも同様のコードがあるが何故?)。
そこで検索してみると
“C Reference Manual” §2.3.1 Integer constants より引用します。Ancient Cでは “10進数(decimal)” と “8進数(octal)” のみが有効です。 16進数(hexadecimal)は 存在しません。
ここで前述のマニュアルを見てもらいたいのだが*2、pre K&Rにはunsignedがないのだ。ポインタは当然unsignedなので、 unsignedを使いたい場合はポインタ(char *)を使っていたのである。いや、なんとも。
KMC Staff Blog:素朴な C (pre K&R C) のお話
キャストも unsigned も存在しないので、符号付き整数を unsigned で扱いたい場合は、ポインタ変数に代入してから計算していたようです。 ポインタは unsigned ですから、アセンブラ的な感覚からすれば、unsigned というキーワードは無くても困りませんね :-)
ということだそうです。 Chistory になにか書いてあるかと思ったのだけど見当たらなかった。 Unix V7のC(pcc)には十六進リテラルは当然あるので、pcc開発時に入ったんだろうか?
話が飛ぶけどLions本は原著も持っていた(日本語版と違って横長の判型)のにすっかり忘れてるなあ。
あと、TurboやDelphiでないPascalに 十六進リテラルあったっけ? というのも引っかかったのだけどよくわからん。
Give Up GitHub
Give Up GitHub - Software Freedom Conservancy
If you’re ready to leave GitHub, you can use this README.md template to replace your current one.
千里之行始於足下
The journey of a thousand miles begins with a single step.
- 老子 (Lao Tsu) in Chapter 64 of 道德经 (Tao Te Ching)
Functional Programming Jargon
関数型プログラミング (FP) における用語集。「高階関数」「関手」「コモナド」「自己準同型」「関数レンズ」など。例はすべてJavaScriptで書かれている。https://t.co/Wtqe95tIe4
— 新山祐介 (Yusuke Shinyama) (@mootastic) July 5, 2022
hemanth/functional-programming-jargon: Jargon from the functional programming world in simple terms! を見るといくつかの言語(自然言語、プログラミング言語)に翻訳されているのだけど
Translations
- Portuguese
- Spanish
- Chinese
- Bahasa Indonesia
- Python World
- Scala World
- Rust World
- Korean
- Polish
- Haskell Turkish
- Haskell Russian
- Julia World
日本語はないんすね。 ということで中国語版 shfshanyue/fp-jargon-zh: 函数式编程术语及示例。本项目译自 を見ると
目录
- Arity
- 高阶组件 (HOF)
- 偏函数应用 (Partial Application)
- 柯里化 (Currying)
- 自动柯里化 (Auto Currying)
- 函数组合 (Function Composition)
- Continuation
- 纯函数 (Purity)
- 副作用 (Side effects)
- 幂等性 (Idempotent)
- Point-Free 风格 (Point-Free Style)
- 谓词 (Predicate)
- 契约 (Contracts)
- Guarded Functions
- 范畴 (Category)
- 值 (Value)
- 常量 (Constant)
- 函子 (Functor)
- 一致性 (Preserves identity)
- 组合性 (Composable)
- Pointed Functor
- Lift
- 引用透明性 (Referential Transparency)
- Equational Reasoning
- 匿名函数 (Lambda)
- Lambda Calculus
- 惰性求值 (Lazy evaluation)
- 独异点 (Monoid)
- Monad
- Comonad
- Applicative Functor
- 态射 (Morphism)
- 自同态 (Endomorphism)
- 同构 (Isomorphism)
- Setoid
- 半群 (Semigroup)
- Foldable
- Traversable
- 类型签名 (Type Signatures)
- Union type
- Product type
- Option
- 函数式编程库
訳されていないものもあるけど、 音訳されたものあり 日本語のそれと似たようなものあり 違ったものありで興味深い。が
匿名函数 (Lambda)
は引っかかるなあ。
もちろん日本語の「匿名」とは
意味が異なる可能性は大いにあるのだけど。
ところでこのページ過去にもHacker Newsで話題になってたのね (5年前と6年前)。
- Functional programming jargon in plain English | Hacker News
- Functional Programming Jargon | Hacker News
- Functional Programming Jargon | Hacker News
704
↑の真ん中あたりに
TRA なんとか
(TRAはアキュムレーター(≠レジスター)の内容をインストラクションカウンター (?プログラムカウンター)に転送する命令)が連続している部分があって、
と前回書いたけどアキュムレーターは関係ありませんでした😓
The Transfer Inatrttbtions
(1) TransferTRA A
is an unconditional control instructiono The next instruc- tion the computer will obey after obeying this one is the instruction in·~locationA. That is, the TRA instruction affects the contents of the instruction location counter. We summarize this as follows:
TRA A A → C(ILC)
There are several conditional transfer instructions. Each of these has associated with it a condition which, if satisfied, causes the computer to take the next instruction from a specified storage location. If the condition is not satisfied, the computer takes the next instructio~ from the next storage location in normal sequence
A → C(ILC)
の部分を早とちりしてしまったのよ😄
まあそれはそれとして、fort1.asmから
$ cut -b 8-10 fort1.asm | sort | uniq -i
のようにしてアセンブラ―のニーモニック(と思われるもの)を抜き出してみると結構あった。 アセンブラーの疑似命令だろうというものも含まれるけど全部調べるの大変そう…
ABS
ACL Add and Carry Logical Word
ADD ADD
ADM ADd Magnitude
ALS Accumrator Left Shift
ANA ANd to Accumrator
ANS ANd to Storage
ARS Accumrator Right Shift
BCD (多分疑似命令)
BES (多分疑似命令)
BSS (多分疑似命令)
BST BackSpace Tape
CAD
CAL Clear and Add Logical word
CAS Compare Accumrator with Storage
CHS CHange Sign
CLA CLear and Add
CLM CLear Magnitude
CLS CLear and Subtract
COM COmpliment Magnitude
CPY CoPY and skip
DCT Divide Check Test
DEC (多分疑似命令)
DVH DiVide or Halt
DVP DiVide or Proceed
END (多分疑似命令)
EQU (多分疑似命令)
ETM Enter Trapping Mode
FAD Floating ADd
FDH Floating Divide or Halt
FDP Floating Divide or Proceed
FMP Floating MultiPly
FSB Floating Subtract
FUL
HED
HPR Halt and PRoceed
HTR Halt and TRansfer
IOD
LBT Low order Bit Test
LDA Locate Drum Address
LDQ
LGL LoGical Left
LLS Logical Left Shift
LRS Logical Right Shift
LTM Leave Trapping Mode
LXA Load indeX from Address
LXD Load index from Decrement
MPR MultiPly and Round
MPY MultiPlY
MSE Minus SEnse
MTH
MTW
MZE
NOP No OPeration
OCT (多分疑似命令)
ORA OR to Accumrator
ORG (多分疑似命令)
ORS OR to Storage
PAX Place Address in indeX
PBT P Bit Test
PDX Place Decrement in indeX
PON
PSE Plus SEnse
PTH
PTW
PXD Place indeX in Decrement
PZE
RCD
RDR
RDS ReaD Select
REL
REM (多分疑似命令)
REP
REW REWind
RND RouND
RPR
RQL Rotate mQ Left
RST
RTB
RTD
RTT Redundancy Tape Test
SBM SuBtract Magnitude
SLF
SLN
SLQ Store Left half mQ
SLT
SLW Store Logical Word
SPR
SSM Set Sign Minus
SSP Set Sign Plus
STA STore Address
STD STore Decrement
STO STOre
STP STore Prefix
STQ STore mQ
STZ
SUB SUBtract
SWT
SXD Store indeX in Decrement
SYN
TIX Transfer on IndeX
TLQ Transfer on Low mQ
TMI Transfer on MInus
TNO Transfer on No Overflow
TNX Transfer on no iNdeX
TNZ Transfer on Non Zero
TOV Transfer on Overflow
TPL Transfer on Plus
TQO Transfer on mQ Overflow
TQP Transfer on mQ Plus
TRA TRAnsfer
TSX Transfer and Set indeX
TTR Trap Transfer
TXH Transfer on indeX High
TXI Transfer with indeX increment
TXL Transfer on indeX Low
TZE Transfer on ZEro
UFA Unnoromalized Floating Add
WDR
WEF Write End of File
WPR
WPU
WRS WRite Select
WST
WTB
WTD
とりあえず、算術式の構文解析と関数やサブルーチンに対する引数の扱いがわかればいいんだけどなあ。