ときどきの雑記帖 RE* (新南口)
The Two Faces of Tomorrow
マイナンバーカード
カンマ
Excelを使って複数のフォルダーを一括作成するウラ技 ~月別フォルダー作成が捗る! - 残業を減らす!Officeテクニック - 窓の杜
BATファイルでは「,」は半角スペースと同じように区切り文字と解釈されるため、今回の例では「md 1月」「md 2月」「md 3月」…、 と順番にmdコマンドを実行するBATファイルが作成されるわけです。
試してみたらたしかに,
でもエラーにならなかった😱
GE帝国盛衰史
自分もちょうど読んでいるところなのだけど
「盛衰史」というよりは「衰亡史」なんじゃないかなあこれ。などと🤔
ところでこの本の原題はLights outで
rms本
rmsのC本をつらつらと眺めていたのだけど、 サンプルコードがやはりというか当然のように GNUスタイルのインデントなのね。
gnu-c-language-manual/Recursive-Fibonacci.md at main · VernonGrant/gnu-c-language-manual
int
fib (int n)
{
if (n <= 2) /* This avoids infinite recursion. */
return 1;
else
return fib (n - 1) + fib (n - 2);
}
こんな感じ。
関数の名前とその引数を括るカッコとの間をあけるのは GNUスタイルの特徴(のひとつ)だと思うんだけど、 これはどういう意味があってそうしているんだろうか。
GNUスタイルではforやifにぶら下がるブレースの置き方も不思議だったのだけど こっちは納得する理由をついさっき思いついた。
gnu-c-language-manual/Iterative-Fibonacci.md at main · VernonGrant/gnu-c-language-manual
int
fib (int n)
{
int last = 1; /* Initial value is fib (1). */
int prev = 0; /* Initial value controls fib (2). */
int i;
for (i = 1; i < n; ++i)
/* If n is 1 or less, the loop runs zero times, */
/* since i < n is false the first time. */
{
/* Now last is fib (i)
and prev is fib (i - 1). */
/* Compute fib (i + 1). */
int next = prev + last;
/* Shift the values down. */
prev = last;
last = next;
/* Now last is fib (i + 1)
and prev is fib (i).
But that won’t stay true for long,
because we are about to increment i. */
}
return last;
}
gnu-c-language-manual/Error-Recovery.md at main · VernonGrant/gnu-c-language-manual
volatile double err, sum, tmp, x, y;
if (fabs (x) >= fabs (y))
{
sum = x + y;
tmp = sum - x;
err = y - tmp;
}
else /* fabs (x) < fabs (y) */
{
sum = x + y;
tmp = sum - y;
err = x - tmp;
}
gawk 5.2.0
前回のgawk 5.1.0 では(タイトル通り)5.1.0までのものだったので、 5.1.xでのものも含めて5.2.0 までの変更点をNEWSで確認。
Changes from 5.1.0 to 5.1.1
- Infrastructure upgrades: Bison 3.8, Gettext 0.20.2, Automake 1.16.4, and (will wonders never cease) Autoconf 2.71.
ビルドするときの話なので省略。
- asort and asorti now allow FUNCTAB and SYMTAB as the first argument if a second destination array is supplied. Similarly, using either array as the second argument is now a fatal error. Additionally, using either array as the destination for split(), match(), etc. also causes a fatal error.
asortとasortiは配列をソートする関数。引数が1個、2個、3個の場合で 動作が微妙に異なるけど(詳細はマニュアル参照)、 FUNCTABやSYMTABが書き換えられるような呼び出し方をするとfatal errorになる。 ソート結果の配列を別に指定すればOK。 同様に、splitやmatchで前述の二つの配列を書き換えるような呼び出しも fatal errorになる。
- The new -I/–trace option prints a trace of the byte codes as they are executed.
実行されたバイトコードのトレースを出力する新オプション。
- A number of subtle bugs relating to MPFR mode that caused differences between regular operation and MPFR mode have been fixed.
MPFR関連のバグ修正。
- The API now handles MPFR/GMP values slightly differently, requiring different memory management for those values. See the manual for the details if you have an extension using those values. As a result, the minor version was incremented.
MPFR/GMP valueを扱うAPIの変更(修正)。 それに伴いAPIのマイナーバージョンがあがった。
- $0 and the fields are now cleared before starting a BEGINFILE rule.
BEGINFILEルールを実行する前に$0や関連するフィールドがクリアされるようになった。 ということは今までは直前の値が残っていたということ?
- The duplication of m4 and build-aux directories between the main directory and the extension directory has been removed. This simplifies the distribution.
省略
- The test suite has been improved, making it easier to run the entire suite with -M. Use `GAWK_TEST_ARGS=-M make check’ to do so.
省略
- Profiling and pretty-printing output has been modified slightly so that functions are presented in a reasonable order with respect to the namespaces that contain them.
プロファイルやプリティプリントの出力結果の変更
- Several example programs in the manual have been updated to their modern POSIX equivalents.
マニュアルの修正
- A number of examples in doc/gawkinet.texi have been updated for current times. Thanks to Juergen Kahrs for the work.
マニュアルの修正
- Handling of Infinity and NaN values has been improved.
無限大やNaNの扱いの改良。
- There has been a general tightening up of the use of const and of types.
- The “no effect” lint warnings have been fixed up and now behave more sanely.
lintの出す警告に関する修正。
- The manual has been updated with much more information about what is and is not a bug, and the changes in the gawk mailing lists.
- The behavior of strongly-typed regexp constants when passed as the third argument to sub() or gsub() has been clarified in the code and in the manual.
マニュアルでのstrongly-typed regexp constantsに関する記述の改善。
- Similar to item #4 above, division by zero is now fatal in MPFR mode, as it is in regular mode.
MPFRを使っているときのゼロ除算がfatal errorになった。
- There have been numerous minor code cleanups and bug fixes. See the ChangeLog for details.
コードのクリーンアップや(minorな)バグ修正。
Changes from 5.1.1 to 5.1.x
- Infrastructure upgrades: Automake 1.16.5, Texinfo 6.8.
省略。
- The rwarray extension now supports writing and reading GMP and MPFR values. As a result, a bug in the API code was fixed.
拡張の話なので省略。
Changes from 5.1.x to 5.2.0
で、5.2.0。 まずは目立つ注意書き
***************************************************************************** * MPFR mode (the -M option) is now ON PAROLE. This feature is now being * * supported by a volunteer in the development team and not by the primary * * maintainer. If this situation changes, then the feature will be removed. * * For more information see this section in the manual: * * https://www.gnu.org/software/gawk/manual/html_node/MPFR-On-Parole.html * *****************************************************************************
- Infrastructure upgrades: Libtool 2.4.7, Bison 3.8.2.
- Numeric scalars now compare in the same way as C for the relational operators. Comparison order for sorting has not changed. This only makes a difference when comparing Infinity and NaN values with regular numbers; it should not be noticeable most of the time.
数値比較のやり方をCのそれと揃えた。
- If the AWK_HASH environment variable is set to “fnv1a” gawk will use the FNV1-A hash function for associative arrays.
環境変数AWK_HASHに"fnv1a"が設定されている場合に 連想配列(の実装)で使用しているハッシュ関数を FNV1-A ハッシュを使用したものにする。
- The CMake infrastructure has been removed. In the five years it was in the tree, nobody used it, and it was not updated.
- There is now a new function, mkbool(), that creates Boolean-typed values. These values are numbers, but they are also tagged as Boolean. This is mainly for use with data exchange to/from languages or environments that support real Boolean values. See the manual for details.
新関数mkbool
- As BWK awk has supported interval expressions since 2019, they are now enabled even if –traditional is supplied. The -r/–re-interval option remains, but it does nothing.
正規表現のinterval expressions({
と}
を使った繰り返し指定)
の扱いの変更。–traditionalが指定されていた場合でも使えるようになった。
これにより-r/–re-interval optionの意味がなくなったが残されている。
- The rwarray extension has two new functions, writeall() and readall(), for saving / restoring all of gawk’s variables and arrays.
拡張rwarray extensionに二つの関数 writeall() と readall() が追加された。
- The new `gawkbug’ script should be used for reporting bugs.
バグレポート用のスクリプト`gawkbug’の新規提供。
- The manual page (doc/gawk.1) has been considerably reduced in size. Wherever possible, details were replaced with references to the online copy of the manual.
gawk.1の内容の整理。
- Gawk now supports Terence Kelly’s “persistent malloc” (pma), allowing gawk to preserve its variables, arrays and user-defined functions between runs. THIS IS AN EXPERIMENTAL FEATURE!
For more information, see the manual. A new pm-gawk.1 man page is included, as is a separate user manual that focuses on the feature.
Terence Kelly’s “persistent malloc” (pma)のサポート。 現状では実験的機能。
- Support for OS/2 has been removed. It was not being actively maintained.
OS/2サポートの削除。
- Similarly, support for DJGPP has been removed. It also was not being actively maintained.
DJGPPサポートの削除。
- VAX/VMS is no longer supported, as it can no longer be tested. The files for it remain in the distribution but will be removed eventually.
VAX/VMSサポートの削除。 関連するファイルはまだ残されているが いずれ削除される。
- Some subtle issues with untyped array elements being passed to functions have been fixed.
関数にuntyped array elements を渡したときの問題の修正。
- Syntax errors are now immediately fatal. This prevents problems with errors from fuzzers and other such things.
- There have been numerous minor code cleanups and bug fixes. See the ChangeLog for details.
collating symbol / equiv class
gnulibのregexでのcollating symbol や equivalence classの扱いについて。
regcomp.c
/* Peek a token from INPUT, and return the length of the token.
We must not use this function out of bracket expressions. */
static int
peek_token_bracket (re_token_t *token, re_string_t *input, reg_syntax_t syntax)
{
switch (c2)
{
case '.':
token->type = OP_OPEN_COLL_ELEM;
break;
case '=':
token->type = OP_OPEN_EQUIV_CLASS;
break;
case ':':
if (syntax & RE_CHAR_CLASSES)
{
token->type = OP_OPEN_CHAR_CLASS;
break;
}
FALLTHROUGH;
default:
token->type = CHARACTER;
token->opr.c = c;
token_len = 1;
break;
}
/* This function parse bracket expression like "[abc]", "[a-c]",
"[[.a-a.]]" etc. */
static bin_tree_t *
parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
reg_syntax_t syntax, reg_errcode_t *err)
{
case EQUIV_CLASS:
*err = build_equiv_class (sbcset,
mbcset, &equiv_class_alloc,
start_elem.opr.name);
if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
case COLL_SYM:
*err = build_collating_symbol (sbcset,
mbcset, &coll_sym_alloc,
start_elem.opr.name,
nrules, table_size, symb_table, extra);
if (__glibc_unlikely (*err != REG_NOERROR))
goto parse_bracket_exp_free_return;
break;
詳細までは(今回は)見ないけどなるほどきちんと動きそうではある。
提起
「COBOLの母」グレース・ホッパーは、COBOLの開発者であるかのように言われていますが、これは間違いであると提起します
— Koichi Nakashima (@ko1nksm) September 15, 2022
COBOLの開発者のJean E Sammetは「COBOLの母でも作成者でも開発者でもない」と答えていますhttps://t.co/QpdsIMt9tp
英語版wikipediaにもCOBOLの開発者とは書かれていません
「提起」の使い方に違和感があるんだけど それは本題ではないので脇によけておいて、
さてそのお名前で検索すると 当然のようにWikipedia(英語版、日本語版共。その他は不明)にエントリもあり
ジーン・E・サメット(Jean E. Sammet、1928年3月23日 - 2017年5月20日[3])は、アメリカ合衆国の計算機科学者である。 プログラミング言語COBOLの開発者の1人であり、1962年にプログラミング言語FORMACを開発した。
逝去のニュースがGIGAZINEやスラドでも取り上げられていた(記憶になかった)。
スラドの記事(スレッド?)はGIGAZINEの記事がもとで立てられたようなのだけど、 GIGAZINEの方にはタイトルにCOBOLが入っているのに スラドの方にはないのは興味深い🤔
- 【訃報】「COBOL」開発者の1人で「FORMAC」生みの親であるジーン・E・サメット氏が89歳で死去 - GIGAZINE
- プログラミング言語FORMACの開発者であるJen E. Sammet氏が逝去 | スラド サイエンス
スラドにはこんなのもあった
んがネタ元の Presidential Medal of Freedom awards go to top computer scientists | Ars Technica には
Rear Admiral Grace Hopper, known as “Amazing Grace” and “the first lady of software,” was at the forefront of computers and programming development from the 1940s through the 1980s. Hopper’s work helped make coding languages more practical and accessible, and she created the first compiler, which translates source code from one language into another. She taught mathematics as an associate professor at Vassar College before joining the United States Naval Reserve as a lieutenant (junior grade) during World War II, where she became one of the first programmers of the Harvard Mark I computer and began her lifelong leadership role in the field of computer science.
とあったり。 確かにここでもCOBOL云々は書かれていないですね。
元ツイートのリンク先の Pioneering software engineer and Cobol co-designer – The Irish Times にはCOBOLに関しての記述はというと結構分量があって
Cobol
Yet her most enduring legacy is the role she played in the creation and longevity of Cobol. By the end of the 1950s, it was becoming clear that computers could be powerful tools not only for scientific calculations but also in business – helping to manage accounting, payroll, purchasing and manufacturing operations. That led to the creation of the Common Business Oriented Language, or Cobol – a means to handle not just numbers, but business data.
Grace Hopper, a computer pioneer at Sperry Rand in the late 1950s, led the effort to bring computer makers together to collaborate on the new programming language. Hopper is often called the “mother of Cobol,” but she was not one of the six people, including Sammet, who designed the language – a fact Sammet rarely failed to point out. (Sammet worked for Sylvania Electric at the time.)
“I yield to no one in my admiration for Grace,” she said. “But she was not the mother, creator or developer of Cobol.”
Sammet and the other five programmers did much of the new language’s design during two weeks of nearly round-the-clock work, holed up in the Sherry-Netherland Hotel in Manhattan. Their proposal was presented in November 1959 and accepted with few changes by the computer makers they worked for and the Pentagon.
As it evolved, Sammet pushed to inject more engineering discipline into the language to make it more useful and reliable in industries such as banking, health care and retailing, and for government agencies.
じゃあなんでGrace HopperがCOBOLの代名詞みたいな扱いになっている(なっていた)んだろうと気になったんだけど(ry
あと、
“I yield to no one in my admiration for Grace,” she said. “But she was not the mother, creator or developer of Cobol.”
これ。I yield to no one in my admiration for Grace,
の部分、そして全体はどう解釈するのがいいんだろう?
Grace Hopperがこの件に関してなにか言っていてそれを参照できるといいんだけど。
FORTRAN Compiler on IBM 704
FORTRAN I
History of FORTRAN and FORTRAN II — Software Preservation Group には、FORTRAN IIコンパイラーのソースコードはあるけれども FORTRAN Iのそれはない。
どうも失われているっぽい?(とは前世紀の昔にも聞いたことがある) そしてFORTRAN IIのソースコードの「発掘」もいろいろ苦労があったようで。
In Search of the Original Fortran Compiler | IEEE Journals & Magazine | IEEE Xplore
自己書き換えプログラム
自己書き換えプログラムが話題に上っていましたが
ABA 自己書き換えは浪漫。Core Warにもそう書かれている
浪漫にマジレスはダサいのだが、その解析の難しさがそのままコードの属人化なので、概念として定着しなかったのだろうなと思う。Z80楽しかったな。
邪道。しかしその邪道がコスト的にもペイした時代があった
わたし個人の話をすると、 スタックに十数バイト~数十バイトのコードを生成して そこに飛びこむコードは(仕事でも)書いたことがあるけど 自己書き換えはなかったかなあ。趣味仕事どちらでも。 まあマスクROMに焼きこむプログラムだとできないよね😄
そして自己書き換えコードと言えばここしばらく追いかけ続けているFORTRAN IIの コードにもあって、たとえばこんな感じ。
REM C0150,2/ CALLS=C0190,DIAG,C0180,C0160. CALLER=C0100. 4F10455
REM C0150 INSPECTS 1ST NB CHAR STARTING IN MQ. IF NUMERIC, SETS I4F10456
REM = 0, AND CONVERTS SUCCESSIVE NUMERICS TO BINARY. IF NON- 4F10457
REM NUMERIC, SETS I = -O, AND PACKS INTO 1G SUCCESSIVE CHARACTERS4F10458
REM UNTIL A ,()= OR ENDMK IS MET, AND LEFT IN THE AC. 4F10459
C0150 SXD C015X,2 SAVE THE C(XR2). 4F10460
TSX C0190,4 * TEST 1ST NON-BLANK CHARACTER 4F10461
CAS L(9) FOR NUMERIC OR NON-NUMERIC. 4F10462
C015X TXI C0151,0,** IF NON-NUMERIC, TRANSFER. 4F10463
NOP IF NUMERIC, THEN 4F10464
TSX C0180,2 * GO CONVERT TO BINARY. 4F10465
STO 2G SAVE NEXT NON-NUERIC CHARACTER. 4F10466
CLA L(0) PREPARE TO SET I TO +0. 4F10467
FWA TXI C0152,0,** GO SET I FOR NUMERIC. 4F10468
C0151 TSX C0160,2 * ASSEMBLE NON-NUMERICS IN 1G. 4F10469
STO 1G SAVE PUNCTUATION MARK, AND 4F10470
CLS L(0) PREPARE TO SET I TO -0. 4F10471
C0152 STO I SET I = +0, OR -0. 4F10472
CLA 2G PICKUP NEXT CHARACTER, 4F10473
LXD C015X,2 RESTORE THE C(XR2), AND 4F10474
TRA 1,2 * RETURN TO CALLER. 4F10475
**
の部分が実行時に書き換えられるところ。
浪漫だの邪道だの言う以前に、 自己書き換えを使わないではプログラムを書けなかったという事情がかつてはあった (Wheeler Jump - Wikipedia) ということですね。
そうそう、X68k(のHuman-68k)用のアーカイバーに xx.xというのがあって(.xは実行ファイルを表す拡張子)、 それはスピードが速い上に 複数のアーカイブ形式に対応しているという優れモノだったのだけど 自己書き換え駆使したアセンブリ言語で書かれているとかきいたことがあったなあ。 解析禁止とドキュメントにあったので実際にどうだったのかは見ていないのだけど。
for
この構文って、Bourne Shell の時点で対応していたのか。勘違いしていた気がする。 https://t.co/Vf0vHCN4u3
— Koichi Nakashima (@ko1nksm) September 13, 2022
なんか前に書いたネタのような… で、確かめたらforには関係していたけどちょっと違った。
for A in "$@";
— eban (@eban) July 2, 2022
じゃなくて
for A;
のように省略してもいい。#シェル芸
というのが気になったので(ry
で、bashのparse.yを見ているんだけど それが今回も関係しているところで、 こんな感じに
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--;
}
略
なるほど ブレースも受け付けている。
そしてV7でどうだったかというと…
v7unix/cmd.c at ed636a47207476db76d53b7869447889dee3bbad · v7unix/v7unix
case FORSYM:
BEGIN
t=getstak(FORTYPE);
t->fortyp=TFOR;
t->forlst=0;
chkword();
t->fornam=wdarg->argval;
IF skipnl()==INSYM
THEN chkword();
t->forlst=item(0);
IF wdval!=NL ANDF wdval!=';'
THEN synbad();
FI
chkpr(wdval); skipnl();
FI
chksym(DOSYM|BRSYM);
t->fortre=cmd(wdval==DOSYM?ODSYM:KTSYM,NLFLG);
break;
END
chksym(DOSYM|BRSYM);
とあるからdo
と{
のどちらでも受け付けると。