[Go to BBS]
All articles in a thread
SubjectSAD Update. V1.0.10.4.13a TYPE, DISP, Close
Article No904
Date: 2011/04/16(Sat) 09:03:36
ContributorK. Oide
Dear Users,

1. The long-time annoying behavior of TYPE and DISP to print everything when the next word matches nothing has been corrected. Now nothing will be printed in such a case. They still print everything, if no words follows. Please do not ask why this has not been cured for more than 20 years.

2. Close now takes more than 1 file numbers. It behaves as:
Close[x__] := Close/@{x};
Close[{x_,y}] := Close/@Range[x,y];

SubjectRe: SAD Update. V1.0.10.4.13a TYPE, DISP, Close
Article No947
Date: 2011/08/05(Fri) 13:29:38
ContributorAkio Morita
今更な話ですが、
> 2. Close now takes more than 1 file numbers. It behaves as:
> Close[x__] := Close/@{x};
> Close[{x_,y}] := Close/@Range[x,y];
で導入されたされた、Range Close構文 Close[{begin_Real, end_Real}]なのですが、
具体的なユースケースはどのようなものでしょうか?

意図しない結果を生み出すユースケースとして、TCPOpen[], TCPAccept[], Pipe[]等の
入力用と出力用のLUNペアを返す一連の関数に対して、Read[], Write[]は
LUNペアを渡すと自動的に使い分ける機能が有ります。
こうしたユースケースでは、プログラマは次のようなコードを無自覚に書く可能性があります。

fd = TCPAccept[];
input = Read[fd];
Close[fd];

問題は、LUNペアを生成する際に LUNを低位から走査して空いている番号を割り付けるので、
LUNペアが連番にならないケースが存在します(当然、間に含まれるLUNは使用中になります)。
このケースでは、Close[fd]で本来意図しない LUNも閉じてしまいます

* Range Closeのユースケースが無いのなら
* Range Closeを廃止する
* Close[{luns__Real}] := Close[luns]にしてしまう
べきだと思うのですが、ユースケースをお持ちの方いらっしゃいませんか?