Programming -- Principles and Practice Using C++

Stroustrup によるプログラミング初学者向けの「Programming -- Principles and Practice Using C++」が 8 月に出版されるようです。

http://www.research.att.com/~bs/programming.html

Preface のドラフトが公開されていますが、じんわりと胸が熱くなるようなとてもいい内容です。

http://www.research.att.com/~bs/programming_pref.pdf

とは言え、この本は読者を選びます。ちょっと長いですが、その下りを引用します。

If your desire is to use the work of others without understanding how things are done and
without adding significantly to the code yourself, this book is not for you. If so, please
consider if you would be better served by another book and another language. If that is
approximately your view of programming, please also consider from where you got that
view and whether it in fact is adequate for your needs. People often underestimate the
complexity of programming and well as its value. I would hate for you to acquire a
dislike for programming because of a mismatch between what you needed and the part of
the software reality we describe. There are many parts of the “Information Technology”
world that do not require knowledge of programming. This book is aimed to serve those
who do want to write nontrivial programs.

意訳:

他人のコードを理解せず、改良もせずにそのまま使うことが望みなら、
この本は君に向いてない。他の本や言語を検討したほうがいいだろう。
また、プログラミングとはただ単にコードを切り貼りするようなもの
だと考えているなら、そう思うようになった経緯と、本当にそういった
切り貼りを君が欲しているかどうかについて、じっくりと考えて欲しい。
プログラミングの複雑さと重要性は、往々にして軽く見られがちだ。
我々が提供するものが君の期待を裏切り、その結果、プログラミングに
嫌悪感を抱くといった事態はできれば避けたい。プログラミングが不要な
"IT" の世界もあるのだから無理をすることはない。この本は重要な
プログラムを書きたいと心から望む人のためにある。

志の高いプロフェッショナルを育てたいという想いがストレートに伝わってきますね。かなりボリュームがありそうですが、原書で味わってみたいです。目次をみる限りでは至って平凡に見える内容を Stroustrup がどのように展開していくのか。興味津々。

新エンジンの進捗

入力メニューと環境設定パネルは表示できるようになりました。入力メニューを表示させるには IMKInputController を継承したクラスで NSMenu* を返すメソッドを用意しておけば OK です。ローカライズもへったくれもない状態ですが、こんな感じになります。

- (NSMenu*)menu {
    NSMenu* inputMenu = [[[NSMenu alloc] initWithTitle:@"AquaSKK"] autorelease];

    [inputMenu addItemWithTitle:[NSString stringWithUTF8String:"環境設定"]
               action:@selector(showPreferences:) keyEquivalent:@""];

    [inputMenu addItemWithTitle:[NSString stringWithUTF8String:"AquaSKK ヘルプ"]
               action:@selector(showHelp:) keyEquivalent:@""];

    [inputMenu addItem:[NSMenuItem separatorItem]];

    [inputMenu addItemWithTitle:[NSString stringWithUTF8String:"Web::プロジェクトホーム"]
               action:@selector(webHome:) keyEquivalent:@""];

    [inputMenu addItemWithTitle:[NSString stringWithUTF8String:"Web::便利な機能、Tips"]
               action:@selector(webTips:) keyEquivalent:@""];

    [inputMenu addItemWithTitle:[NSString stringWithUTF8String:"Web::FAQ"]
               action:@selector(webFAQ:) keyEquivalent:@""];

    return inputMenu;
}

各項目が選択されると、self をターゲットにしてアクションに指定したセレクタが呼び出されます。例えば環境設定なら、以下のようなメソッドを用意しておきます。

- (void)showPreferences:(id)sender {
    [[NSWorkspace sharedWorkspace] launchApplication:@"Preferences"];
}

あっけないくらい簡単ですね。

なお、IMK を使う場合には入力メソッドをバックグラウンド専用アプリケーションにする必要があるのですが、そうなると環境設定パネルもアクティブにならないため、環境設定を別アプリケーションにしました。ことえりも同じ方式のようです。