これはどうなのだろう…
dmdをリコンパイル可能にしてくれとの話の流れで空気読まずにランタイムコンパイルの話だしたら、Article first draft: The Joy and Gibbering Terror of Custom-Loading Executablesってスレッド教えてもらった。それはいいんだが、そのコードのエラーの部分が興味深かったからコピペ。(ライセンスはThis code is free to do with as you please.とある。)
/// Root of any executable error. class ExecutableError : Error { /// Just pass on the _message to the base class. this (string message) { super (message); } /// Thrown when loading fails for some reason. static class Load : ExecutableError { this (string filename, string message) { super ("Loading \"" ~ filename ~ "\" failed: " ~ message); } } /// Thrown when linking fails. static class Link : ExecutableError { /// List of missing externs. This may be null. string [] missing; /// Create the message and assign the parameters. missing may be null. this (string [] missing) { this.missing = missing; string message = "Could not link executable"; if (missing.length) { message ~= ", these externs were not found: "; foreach (index, item; missing) { if (index) message ~= ", "; message ~= item; } } message ~= "."; super (message); } } }
ネストクラスがouterクラスを継承している。ええと、これは要するに名前の個数を減らすためにか?
もうちょっと考える必要有り。
違うか。名前が被ってこう実装してるんだな、多分。