ときどきの雑記帖 RE* (新南口)
秘伝の
秘伝の
「代々受け継がれた秘伝のたれ」的な「秘伝のソースコード」 って話はたまに聞いたりしましたが、 「秘伝のExcelファイル」を目にする日が来るとは思わなかった(謎)
法網
例の、南武線車内で流されているニュースの 中文表記で「法網」(簡体字は出し方わからないので略)というのを 先週(6/7(月)からの週)見かけたのだけどどういう意味なんだろう。これ。 ニュースの内容からすると「テニス」のことだろうと思われるのだけど、 「テニス 中国語」とかで検索すると「網球」というのが出てくるし、 「法網 中国語」で検索すると (文字通りの?)「法の網」といった説明をしているページしか見当たらない。
なにがなにやら。
この「法網」、以前にも見たことがある(そのときも調べたけど空振り)ので 見間違いということはないと思うんだけどなあ。
写真を撮れれば良かったんだけど、スマホ握りながらニュース見てたわけではないし、 気がついてから撮ろうとしても間に合わない。
単徳
今日(6/14)もテニスのニュースででてきた>「法網」
あと、「法網男単徳~」と言うのが見えたのだけど これ、テニスの男子シングルスってことですかね。
「単」だけでシングルスなのか。
ショットボトル
トランク付きエレベーター
6/12放送のピタゴラスイッチで知ったのだけど、こういう構造のエレベーターがあったのか。
Pythonic
どうも「Pythonic」がどういうこと(もの)なのかよくわからなくなった。
ヴァンロッサムは、他のプログラミング言語についての考えを述べ、C++のコードを改善するRustの能力を賞賛し、 新しい「Pythonic」プログラミング言語の中で最も興味深いものの1つとしてGoを挙げました。
Programming languages: Why Python 4.0 might never arrive, according to its creator - TechRepublic
Van Rossum shared his thoughts on other programming languages, saying he admired Rust’s ability to improve C++ code and citing Go as one of the most interesting new “Pythonic” programming languages.
なんとなくわかるような気もするんだけど、具体的にGoのどういった部分が (その他の言語と比較してより)「Pythonic」なんだろうか?🤔
「Python」の弱点やそのとらえ方–生みの親、グイド・ヴァンロッサム氏が語る - (page 2) - ZDNet Japan から。英語部分の引用は Programming languages: Why Python hasn’t taken off on mobile, or in the browser - according to its creator | ZDNet
しかし同氏は「そういったニッチな領域で作業する場合、JuliaはコンパイラーによってPythonでは望めないほどの最適化が達成されるため、 素晴らしい言語だと言える」と付け加えた。ただ、「一方、それ以外の領域で作業する場合、Juliaはずっと制約の多い言語だ。 Juliaでウェブサーバーを開発して、さまざまなことを実行したいと考える人など誰もいないと私は考えている」とも述べた。 なお、van Rossum氏はRustのファンでもあるが、Googleが生み出したGoが最近の新言語すべてのなかで最も「Pythonっぽい」と考えているという。
But he added: “If you’re in that niche, it is superior because the compiler optimizes your code in a way that Python probably never will. On the other hand it is much more limited in other areas and I wouldn’t expect that anybody ever is going to write a web server in Julia and get a lot of mileage out of it.” Van Rossum is also fan of Rust but he reckons Google-created Go is the most “Pythonic” of all the new languages.
Pythonic is an adjective that describes an approach to computer programming that agrees with the founding philosophy of the Python programming language. There are many ways to accomplish the same task in Python, but there is usually one preferred way to do it. This preferred way is called “pythonic.”
ふむ。
ブログ: Pythonの生みの親グイド・ヴァンロッサムが考えるRust、Go、Julia、TypeScriptとは
リダイレクト記法
Bashの入出力リダイレクトまとめ - Qiita を見ていて
NOTE:
&> は >& に置き換え可能だが、Man page of BASHによれば好ましいのは前者らしい。 同様に、&» は »& に置き換え可能。 &>, &» 辺りはBash以外のシェルでは動かないことがあったと思う。
へー、そんなのあったのかと思ってリンク先の Man page of BASH を見るとたしかにそう書いてある(知らなかったよ…)。 が、「なんで?」と言うのが気になった。
残念ながらこのMan pageにはなかったので調べてみることにした。 また、「Bash以外のシェルでは~」ということなので、zshとPOSIXも併せて調べる。
Bash Reference Manual
まずはマニュアルから。
3.6.4 Redirecting Standard Output and Standard Error
This construct allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word.
There are two formats for redirecting standard output and standard error:
&>word
and
>&word
Of the two forms, the first is preferred. This is semantically equivalent to
>word 2>&1
先ほどのMan pageの記述と同じですね。ただこちらでは続く部分に
When using the second form, word may not expand to a number or ‘-’. If it does, other redirection operators apply (see Duplicating File Descriptors below) for compatibility reasons.
と書いてあって、これが&
を先に置く方が望ましいとする理由なのかな。と。
zsh
次にzsh。
zshもこの記法を許していて、
>& word
&> word(Except where ‘>& word’ matches one of the above syntaxes; ‘&>’ can always be used to avoid this ambiguity.) Redirects both standard output and standard error (file descriptor 2) in the manner of ‘> word’. Note that this does not have the same effect as ‘> word 2>&1’ in the presence of multios (see the section below).
opengroup
次に opengroupのページから。
2.7.6 Duplicating an Output File Descriptor
2.7.6 Duplicating an Output File Descriptor
The redirection operator:
[n]>&word
shall duplicate one output file descriptor from another, or shall close one. If word evaluates to one or more digits, the file descriptor denoted by n, or standard output if n is not specified, shall be made to be a copy of the file descriptor denoted by word; if the digits in word do not represent a file descriptor already open for output, a redirection error shall result; see Consequences of Shell Errors. If word evaluates to ‘-’, file descriptor n, or standard output if n is not specified, is closed. Attempts to close a file descriptor that is not open shall not constitute an error. If word evaluates to something else, the behavior is unspecified.
&が先に来る記法はなさそう。 たぶんkshもそうなんだろう(fishは知らん)。
脱線
2.7.7 Open File Descriptors for Reading and Writing
The redirection operator:
[n]<>word
shall cause the file whose name is the expansion of word to be opened for both reading and writing on the file descriptor denoted by n, or standard input if n is not specified. If the file does not exist, it shall be created.
お、これはあるのか。
脱線2
2.9.2 Pipelines
で
The format for a pipeline is:
[!] command1 [ | command2 …]
というのを見つけ、先頭にある(省略可能な)!
ってなんじゃこれ。と。
その説明は直後に書いてあって、
If the pipeline begins with the reserved word ! and command1 is a subshell command, the application shall ensure that the ( operator at the beginning of command1 is separated from the ! by one or more
characters. The behavior of the reserved word ! immediately followed by the ( operator is unspecified.
ふむ?
NEWS
ということで、いつ頃からあるものなのかとりあえずbashのNEWSの記述から辿ってみる。
bash/NEWS at master · bminor/bash
cc. There is a new &» redirection operator, which appends the standard output and standard error to the named file.
bash/NEWS at master · bminor/bash
This is a terse description of the new features added to bash-4.0 since the release of bash-3.2. As always, the manual page (doc/bash.1) is the place to look for complete descriptions.
と、&>>
については3.2→4.0の時点で入ったらしいことはわかったのだけど
&>
については見当たらなかった。このファイルにはずいぶん昔(1.x)からの
記録が残っていたので、そこにないということは(記述漏れがなければ)
かなり以前からあったということか(知らなかったよ(本日二度目))。
older versions
じゃあと Index of /gnu/bash にある 古いバージョンのtar玉を見てみると
1.14.7
1.14.7同梱のドキュメントに以下の記述を発見。
Redirecting Standard Output and Standard Error
Bash allows both the standard output (file descriptor 1) and the standard error output (file descriptor 2) to be redirected to the file whose name is the expansion of word with this construct.There are two formats for redirecting standard output and standard error: &>word and >&word Of the two forms, the first is preferred. This is semanti- cally equivalent to >word 2>&1
この時点ですでにあった。ということですね。 残念ながら先のディレクトリに置かれているものはこれが一番古いので これ以上は遡れない…と思ったが
1.05
Index of /Linux.old/bin/old/bash-1.05/ に、どこまで信用してよいかわからないけど1.05のものだというソースコードがあったので 1.14.7のものと比較してみた(ドキュメントが見当たらなかったのよ)。
1.14.7 parse.y:1905
else
{
if (peek_char == '&')
{
switch (character)
{
case '<': return (LESS_AND);
case '>': return (GREATER_AND);
}
}
if (character == '<' && peek_char == '>')
return (LESS_GREATER);
if (character == '>' && peek_char == '|')
return (GREATER_BAR);
if (peek_char == '>' && character == '&')
return (AND_GREATER);
}
shell_ungetc (peek_char);
1.05
else
{
if (peek_char == '&')
{
switch (character)
{
case '<': return (LESS_AND);
case '>': return (GREATER_AND);
}
}
if (peek_char == '>' && character == '&')
return (AND_GREATER);
}
いくつか違いがあるものの、&>
については1.05の時点ですでにあったようで。
68000
いいよね。68000 (「欠点」は承知の上で)。
今の時代に68000のアセンブラを教えている研究室あるのかー。そうなのかー。https://t.co/AtoYOQdYBC
— とげとげP @めっぽう気さく (@checkela) June 12, 2021
globネタは今回お休みなのじゃ。