トップ «前の日記(2017-06-09(Fri)) 最新 次の日記(2017-06-15(Thu))» 編集

屑俺日記

僕の備忘録(PC、UN*X、ネットワーク関連が中心)なんです。
自分の書いたところは適当(な時とか)に書き換えますので御了承を。


2017-06-13(Tue) 普通に晴れ

久々のpython

当初2で書いたが、 githubに上げる前に3向きにする。

$ python3 4div_list.py3 12345678
12345678
[12, 34, 56, 78]

別言語のことを考えて、python特有の機能は一応避けたつもり。

簡単に死ぬ

void setup() {
  size(10, 10);
}
 
void draw() {
  int times = int(pow(2, 10));
  for (int x = 0; x < times; x++) {
    println("hello,", x);
  }
  noLoop();
}

繰り返し回数が1024回くらいなら大丈夫だったが、65536回実行すると

Listening for transport dt_socket at address: 8590
hello, 0
hello, 1
hello, 2
.
.
.
hello, 65533
hello, 65534
hello, 65535
java.lang.ArrayIndexOutOfBoundsException
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException

300行ほど"Exception ..."を吐いて強制終了となった。
何度か繰り返したが、落ちるまでの回数は決まってなさげ。
動作中にtop(1)を眺めていると、実行プロセスの %CPUが352くらいになったりする。

printlnの注意事項を見る限り、目的外使用に近い気もするが。


リンクはご自由にどうぞ。でもURLや内容が変った場合はあしからず。

index.htmlは ここから。