ときどきの雑記帖 RE* (新南口)
さようなら、いままでビットをありがとう
Windows Terminal
起動時にタブを二つ(PowerShellとcmd.exe)を開くようにしたいのだけどどうすれば?
という話。忘れたころに意外なところで解決。
「ターミナル」アプリ(Windows Terminal)を使いやすくする基本設定:Tech TIPS - @IT
それには、[設定]タブの[スタートアップ]画面を開き、「ターミナルの起動時」欄のプルダウンリストで [前のセッションからウィンドウを開く]を選択しておけばよい。
細かいこと言うと 自分がやりたかったこととは微妙に違うのだけど、 得られる結果がそれなりに満足いくものだから いいのだ。
GNU Make 4.4
- WARNING: Backward-incompatibility!
- New feature: The $(let …) function
Eternal September
HNを眺めていたら「Mastodon’s eternal September begins?」というタイトルが目についた。 「えいえんの9月」とはどういうこと? と調べるととある故事(謎)に由来する言い回しらしい。
- Mastodon’s eternal September begins? | Hacker News
- Home invasion
- eternal septemberの意味・使い方・読み方 | Weblio英和辞書
- Eternal September - Wikipedia
日本でいうとNifty-Serveが接続した日になるんかね。
水先人
とあるTV番組を観ていたら「みずさきにん」なる人が出てきて、 そりゃ「水先案内人」じゃないの? と思って調べると
日本語で一般には「水先案内人(みずさきあんないにん)」と呼ばれることの方が多く、正式名称の「水先人」は法律用語である[2]。 これに派生して、船舶に限らず様々な事柄に対しても、先導して行く先を示し、導く人のことを「水先案内人」「水先案内」と呼ぶ。
へー。
さようなら、いままでビットをありがとう
HNを見ていたら「おや?」 と思うようなタイトルのついた エントリがあった(本日二個目)。
元記事の最初には
Ian Levy, the NCSC’s departing Technical Director, discusses life, the universe, and everything.
とあったりイルカの画像が貼られていたりで、これは 「さようなら、いままで魚をありがとう」(So long and thanks for all the fish) だよねえ。と。 実際HNの方にも同様の指摘があった。
thanks for all the bits Am I missing something here? What’s the headline supposed to mean? Is it a tongue-in-cheek gesture, since GCHQ routinely hoover up personal data and spy on both their citizenry and foreign countries?
I think it’s a reference to “Hitchhiker’s Guide to the Galaxy”. Knowing Earth was going to be destroyed the dolphins leave, but they leave behind a message which when decoded translates to “so long and thanks for all the fish” (referring to how dolphins had trained humans to give them a fish when they did tricks).
元記事はいわゆる退職エントリのようで、 その辺に引っ掛けたタイトルだったんだろう。
B-17の話は面白かった(こなみかん)。
über alles
江添さんが紹介し翻訳していたredditの書き込みについてのはてブのコメントで
[B! emacs] ドイツでは航空交通管制にEmacsが使われていた
訳文中「本物のプログラマー」は原文では Herr Doktor 。ドイツの教育は小学校の内申点で大学進学可否が最終的に決まる階級差別の激しい制度で、 博士号取得者のエゴと権力はまさに über alles 。それを表している。
というのが目についたので原文を読んでみることにした。
Herr Doktorという言葉については(知識がないので) いうことはないのだけどいくつか気になる点はあって、 たとえば
Do you use Emacs Lisp as a general purpose programming language? : emacs
GCCのコンパイルに最も時間がかかった。まともなコンパイラーを手に入れるまで3段か4段のビルドステージを経なければならない。 とはいえ1日かけて、HP/UXにEmacsを導入した。
というのの原文を見ると
GCC took the longest, you need three or four build stages before you have a reliable compiler, but a day later I had Emacs on HP/UX.
であり、なぜGCCのビルドに何段階もあるのかを考えれば
reliable compiler
を
「まともなコンパイラー」
としてしまうのはちょっと「乱暴」なんじゃないかなあ。
あと
Pro tip: don’t look in the kitchen when governments brew up safety critical systems. I was scared to fly over Germany for a while…
の最初の文が欠落しているのも気になる。
まああの人はいつもこんな感じ(の翻訳)だけど。
Mel
- LGP-30 found in basement, the same model of drum computer programmed by “Mel” | Hacker News
- I found ancient computers in the basement of my grandparents (LGP-30 and PDP 8e) : vintagecomputing
- Redditor discovers legendary 1956 computer in grandparents’ basement | Ars Technica
- 1956年発売の伝説的コンピューター「LGP-30」を地下室で発見したとRedditユーザーが報告 - GIGAZINE
みたいな記事が(ちょっと時間をおいて)出てくるとか 西亭新九郎 が仕事しとるな😄
そう言えばGIGAZINEの記事で知ったのだけど、うぃきぺ(英語版)に The Story of Melの項目 があったのね。さすがだ。
それと前回もリンクを貼った
Mel’s Loop - A Comprehensive Guide to The Story of Mel
をざっと読んでみたのだけど
The Story of Mel
で描写されていたプログラムの動きの詳細を知るのに良さそう。
ところで「GIFAZINEだから」と言ってしまえばそれまでなのだけど
LGP-30が希少とされているのは現存数が少ないからだけでなく、「The Story of Mel(メルの物語)」というハッカー伝説の中で 「真のプログラマー」とうたわれているメルことMelvin Kayeにまつわる機種でもあるためです。
「メルの物語」は、LGP-30のメーカーであるLibrascopeに勤務していたメルが、トランプゲームのブラックジャックのプログラムを LGP-30から他製品に移植する仕事を任された際に、天才的かつ独創的なプログラミングでそれを行ったという逸話です。 「メルの物語」の中で、著者でありメルが残したプログラムのデバッガーでもあったエドワード・ナザーは、 あまりにも素晴らしいコードだったため畏敬の念のあまりデバッグを中止して「バグはなかったと報告した」と語りました。
大間違いと言わないまでもなんか引っかかる説明だなあ。
うぃきぺの The Story of Mel - Wikipedia による説明だとこう。
The story, as written by Nather, involved Kaye’s work on rewriting a blackjack program from the LGP-30 to a newer Royal McBee system, the RPC-4000; company sales executives had requested to modify the program so that they could flip a front panel switch and cause the program to lose (and the user to win). Kaye reluctantly acceded to the request, but to his own delight, he got the test wrong, and the switch would instead cause the program to win every time (and the user to lose).
LGP-30 とRPC-4000の関係が良くわからない(知らなかった)のだけど 同じくうぃきぺにあるLGP-30のページにRPC-4000の項があった。
Another, more-powerful successor machine, was the General Precision RPC 4000, announced in 1960.[15] Similar to the LGP-30, but transistorized, it featured 8,008 32-bit words of memory drum storage. It had 500 transistors and 4,500 diodes, sold for $87,500 and weighed 500 pounds (230 kg).[16][17][18]
The Story of Melに出てくる「インデックスレジスター」は LGP-30の解説のところにも見当たらない気がするんだけど わたしの見落としかな?
Arithmetic element: three working registers: C the counter register, R the instruction register and A the accumulator register.
というのはあるのだけど。
The Story of Melでインデックスレジスターが登場するのはこのあたり。
The Story of Mel, A Real Programmer
The RPC-4000 computer had a really modern facility
called an index register. [60]
It allowed the programmer to write a program loop
that used an indexed instruction inside;
each time through,
the number in the index register
was added to the address of that instruction,
so it would refer
to the next datum in a series. [61][62]
He had only to increment the index register
each time through.
Mel never used it.
The vital clue came when I noticed
the index register bit, [67]
the bit that lay between the address
and the operation code in the instruction word, [68]
was turned on — [69]
yet Mel never used the index register,
leaving it zero all the time. [70]
When the light went on it nearly blinded me.
ref
- Mel’s Hack - The Missing Bits | Hacker News
- Mel’s Hack - The Missing Bits
- Mel’s Loop - A Preface to The Story of Mel
- The ‘Story of Mel’ Explained | James Seibel
- The Story of Mel, A Real Programmer, Annotated
- The Story of Mel - Wikipedia
- Self-modifying code - Wikipedia
- Macho programmers, drum memory and a forensic analysis of 1960s machine code
- The second decade of programming: Big Iron | HackerNoon
おまけ
HN LGP-30 found in basement, the same model of drum computer programmed by “Mel” | Hacker News で盛り上がっていた話の中で
5 bit Friden Flexowriter punching paper tape for coding in machine language. Coding sheets. Weird hexadecimal digits 0-9fgjkqw (it took me a while to adapt to 0-9a-f when I first saw them!)
といった書き込みが。 16進数の表記でABCDEFの代わりにFGJQRを使っていた? なぜそうなっているかの推測(?)もある。
C# F#
いつの間にやらF#のバージョンも7ですか。
F#と言えば「下駄の兄貴」はお元気だろうか。
- Welcome to C# 11 : programming
- Welcome to C# 11 - .NET Blog
- What’s new in C# 11 - C# Guide | Microsoft Learn
新機能がいろいろあるのだけど
var u8 = "This is a UTF-8 string!"u8;
UTF-8であることを示すu8
が文字列の末尾につくのは面白いなとか
The type parameter T is constrained by the IMonoid
interface, and that allows the static virtual members of that interface – Zero and + – to be called on T itself!
Welcome to C# 11 | Hacker News
Monoid
T AddAll<T>(params T[] elements) where T : IMonoid<T> => elements switch { [] => T.Zero, [var first, ..var rest] => first + AddAll<T>(rest), };
モノイド?
clawn
blawn 僕は消費者ではなく、創造者の立場に立ちたい──NEXT TECH PLAYER 賞は中学3年生で「Blawn」を開発した上原直人さん - TECH PLAY Magazine の作者の新作。
GitHub - Naotonosato/Clawn: The Clawn Programming Language
blawnでもそうだったけど、 あまり情報が出回っていない(少なくとも日本語では) と思われるbisonの機能をバシバシ使っている割に
parse.yy
%skeleton "lalr1.cc"
%require "3.0"
%debug
%defines
%define api.namespace {clawn::compiler}
%define api.parser.class {Parser}
%locations
%language "c++"
%{
#define YYDEBUG 1
%}
%code requires{
...
%parse-param { Lexer &lexer }
%parse-param { Driver &driver }
%right RETURN
%token EOL
%token END 0 "end of file"
定義している構文規則は 「なんでこうしてるんだろう?」 と思うようなものがそこそこあるのが気になるっちゃ気になるが、 まあ以下略(もごもご)
それから、
github上のソースツリーにbuild/
ってディレクトリはリポジトリに含める必要ないんじゃないか?
と思っていたら、
プルリクエスト
があって
Clawn/.gitignore
に追記されてた(github上からはなくなった)。
軽くソースコードも眺めてみたけど
- prelexeer.ll
- lexer.ll
この二つの使い分けというかそれぞれの役割がよくわからん。
ref
- Blawnの文法について
- ウワサのBlawnを触ってみた - Qiita
- [B! programming] GitHub - Naotonosato/Blawn: Pleasant Programming Language.
- [B! language] GitHub - Naotonosato/Clawn: The Clawn Programming Language
- 本文 「blawn」 を検索 - はてなブックマーク
rusty_awk
こっちは動きがないな…
GitHub - kat0h/rusty_awk: 作りかけ
gawk
何の気なしに gawk.git - gawk を眺めていたら NEWSファイルの更新 gawk.git - gawk というのがあって、なんだろうと思って中身を見ると
diff --git a/NEWS b/NEWS
index 6d52e17..b2ab6d2 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,14 @@
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.
+Changes from 5.2.1 to 5.3.0
+---------------------------
+
+1. In keeping with new features in BWK awk, gawk now has built-in
+ CSV file parsing. The behavior is intended to be identical to
+ that of the "One True AWK", when FS = "," is applied. See the
+ manual for details.
+
え?>「In keeping with new features in BWK awk, gawk now has built-in CSV file parsing.」
詳しくはマニュアルを読めともあるので探してみた。 ここかな。
gawk.texi\doc - gawk.git - gawk
@node Comma Separated Fields
@subsection Working With Comma Separated Value FilesMany commonly-used tools use a comma to separate fields, instead of whitespace. This is particularly true of popular spreadsheet programs. There is no universally accepted standard for the format of these files, although @uref{http://www.ietf.org/rfc/rfc4180.txt, RFC 4180} lists the common practices.
For decades, anyone wishing to work with CSV files and @command{awk} had to ``roll their own’’ solution. (For example, @pxref{Splitting By Content}). In 2023, Brian Kernighan decided to add basic CSV support to his version of @command{awk}. In order to keep up, @command{gawk} too provides the same support as his version. To use CSV data, set @code{FS} equal to a string with a single comma, like so: @samp{FS = “,”}.
Fields in CSV files are separated by commas. In order to allow a comma to appear inside a field (i.e., as data), the field may be quoted by beginning and ending it with double quotes. In order to allow a double quote inside a double-quoted field, two double quotes are used. @ref{table-csv-examples} shows some examples.
In 2023, Brian Kernighan decided to add basic CSV support to his version of @command{awk}.
とあるけど、onetrueawkのリポジトリでそんな動きあったかしらん?
(見落としている可能性は大いにある)
まあそれはさておき、対応する(マニュアルのソースに対する)コミットはこれっぽい gawk.git - gawk (最初は見つけられなかった)
差分
diff --git a/doc/gawk.texi b/doc/gawk.texi
index 61e740f..7b37f89 100644
--- a/doc/gawk.texi
+++ b/doc/gawk.texi
@@ -568,6 +568,7 @@ particular records in a file and perform operations upon them.
* Regexp Field Splitting:: Using regexps as the field separator.
* Single Character Fields:: Making each character a separate
field.
+* Comma Separated Fields:: Working with CSV files.
* Command Line Field Separator:: Setting @code{FS} from the command
line.
* Full Line Fields:: Making the full line be a single
@@ -7758,6 +7759,7 @@ with a statement such as @samp{$1 = $1}, as described earlier.
* Default Field Splitting:: How fields are normally separated.
* Regexp Field Splitting:: Using regexps as the field separator.
* Single Character Fields:: Making each character a separate field.
+* Comma Separated Fields:: Working with CSV files.
* Command Line Field Separator:: Setting @code{FS} from the command line.
* Full Line Fields:: Making the full line be a single field.
* Field Splitting Summary:: Some final points and a summary table.
@@ -8014,6 +8016,45 @@ In compatibility mode
if @code{FS} is the null string, then @command{gawk} also
behaves this way.
+@node Comma Separated Fields
+@subsection Working With Comma Separated Value Files
+
+Many commonly-used tools use a comma to separate fields, instead of whitespace.
+This is particularly true of popular spreadsheet programs. There is no
+universally accepted standard for the format of these files, although
+@uref{http://www.ietf.org/rfc/rfc4180.txt, RFC 4180} lists the common
+practices.
+
+For decades, anyone wishing to work with CSV files and @command{awk}
+had to ``roll their own'' solution. (For example, @pxref{Splitting By Content}).
+In 2023, Brian Kernighan decided to add basic CSV support to his version of
+@command{awk}. In order to keep up, @command{gawk} too provides the same
+support as his version.
+To use CSV data, set @code{FS} equal to a string with a single comma, like so: @samp{FS = ","}.
+
+Fields in CSV files are separated by commas. In order to allow a comma
+to appear inside a field (i.e., as data), the field may be quoted
+by beginning and ending it with double quotes. In order to allow a double
+quote inside a double-quoted field, two double quotes are used.
+@ref{table-csv-examples} shows some examples.
+
+@float Table,table-csv-examples
+@caption{Examples of CSV data}
+@multitable @columnfractions .3 .3
+@headitem Input @tab Field Contents
+@item @code{abc def} @tab @code{abc def}
+@item @code{"quoted data"} @tab @code{quoted data}
+@item @code{"quoted, data"} @tab @code{quoted, data}
+@item @code{"She said ""Stop!""."} @tab @code{She said "Stop!".}
+@item @code{She said "Stop!".} @tab @code{She said "Stop!".}
+@end multitable
+@end float
+
+The double-quote that starts a quoted field must be the first
+character after the comma.
+
+This featue is disabled in POSIX mode.
+
@node Command Line Field Separator
@subsection Setting @code{FS} from the Command Line
@cindex @option{-F} option @subentry command-line
@@ -8260,6 +8301,10 @@ of @code{FS} (@samp{==} means ``is equal to''):
Fields are separated by runs of whitespace. Leading and trailing
whitespace are ignored. This is the default.
+@item FS == ","
+Fields are separated by commas, with quoting of fields
+and special rules involved.
+
@item FS == @var{any other single character}
Fields are separated by each occurrence of the character. Multiple
successive occurrences delimit empty fields, as do leading and
FORTRAN Compiler on IBM 704
うぃきぺ(英語版)のFORTRANのエントリを読んでいたらこんな記述を発見した。
Columns 73 to 80 could therefore be used for identification information, such as punching a sequence number or text, which could be used to re-order cards if a stack of cards was dropped; though in practice this was reserved for stable, production programs.
へー。
4K/8K
REM ----------- SCANNED 10/8/06 304349-Volume_I.pdf Page 035/035 --------
REM APPLIED PROGRAMMING, IBM , L. MAY AND A. S. NOBLE JR.
REM 704 FORTRAN II / SECTONR ONE. 29 OCT 58
REM
REM SECTION 1= READS IN AND CLASSIFIES STATEMENTS. FOR ARITHMETIC4F10000
rem ------ scanned 8/9/07 304349-Volume_II.pdf Page 238/678 ------
REM APPLIED PROGRAMMING, IBM , L. MAY AND A. S. NOBLE JR.
REM 704 FORTRAN II / SECTION ONE. 29 OCT 58
REM 8K VERSION WITHOUT CODING ON DRUMS.
REM
REM SECTION 1= READS IN AND CLASSIFIES STATEMENTS. FOR ARITHMETIE4F10000
B
FORTRAN IIのソースコードでいくつか見つかる 定数定義(と思われる)の末尾にある B{数値} ってなんじゃこれ。
grep -e "^.\{7\}DEC [0-9,]\+B" fort1.asm
M1CON DEC 0,1,2,3,4,10B17,1B17,2B17,4B17,8B17,17B17,18B17,35B17 F3B11740
M2CON DEC 0,1,2,4,6,8,16,1B17,3B17 F3B12600
L(1D) DEC 1B17 F3B06220
ONED DEC 1B17 F3B06430
L(2D) DEC 2B17 F3B06440
Z2K4 DEC 3B14 F5G35980
15P DEC 15B5 CONSTANT USED BY IOT. 4F10387
Z2K4 DEC 3B14 F5G35980
K1 DEC 155B8 CONSTANT USED BY DBC. DBC/520
K2 DEC 170B8 CONSTANT USED BY DBC. DBC/521
K3 DEC 1B9 CONSTANT USED BY DBC. DBC/522
K4 DEC 221B8 CONSTANT USED BY DBC. DBC/523
K5 DEC 35B8 CONSTANT USED BY DBC. DBC/524
FIXN DEC 155B8 CONSTANT USED BY FIL/BDC. BDC/582
FIXQ DEC 182B8 CONSTANT USED BY FIL/BDC. BDC/583
BIAS DEC 27B8 CONSTANT USED BY FIL/BDC. BDC/584
FIXN DEC 155B8 CONSTANT USED BY FIL/BDC. BDC/582
FIXQ DEC 182B8 CONSTANT USED BY FIL/BDC. BDC/583
BIAS DEC 27B8 CONSTANT USED BY FIL/BDC. BDC/584
BASE DEC 128 CONSTANT USED BY FIL/BDC. BDC/585
LOG2 DEC .301029957B CONSTANT USED BY FIL/BDC. BDC/586
ONE DEC 1 CONSTANT USED BY FIL/BDC. BDC/587
TWO PZE 2 CONSTANT USED BY FIL/BDC. BDC/5875
L(9) PZE 9 CONSTANT USED BY FIL/BDC. BDC/5876
DEC .5BE-9 09-TABLE USED BY FIL/BDC. BDC/588
DEC .5BE-8 08-TABLE USED BY FIL/BDC. BDC/589
DEC .5BE-7 07-TABLE USED BY FIL/BDC. BDC/590
DEC .5BE-6 06-TABLE USED BY FIL/BDC. BDC/591
DEC .5BE-5 05-TABLE USED BY FIL/BDC. BDC/592
DEC .5BE-4 04-TABLE USED BY FIL/BDC. BDC/593
DEC .5BE-3 03-TABLE USED BY FIL/BDC. BDC/594
DEC .5BE-2 02-TABLE USED BY FIL/BDC. BDC/595
DEC .5BE-1 01-TABLE USED BY FIL/BDC. BDC/596
RND DEC .5B 00-TABLE USED BY FIL/BDC. BDC/597
8の誤認識かとも思ったのだけど どうもそうではなさげ。