07/08/06 16:24:44
>>185
空のchar[]とnullは区別できないよ。
import std.stdio;
void main() {
writefln("" is null); // false
// 文字列リテラルはNULターミネータを持っている。
char[] s;
writefln(s is null); // true
// 配列の初期値はnull
s = "".dup;
writefln(s is null); // true
// NULターミネータは複製されない。
s = "aa".dup; s.length = 0;
writefln(s is null);
// 長さを 0 にしても再利用のため(?)に同じ場所を指し続けている
}