タグ

2008年7月29日のブックマーク (2件)

  • 2004-10-02

    最近C++を使う時間が長いのでががーっと C++批判文章を書き上げてみる…。 (注:以下の文章において、C言語とはC/C++をさすものとお考えください) gotoは今から30年以上も前のダイクストラ先生による撲滅運動の 甲斐もあってかどうなのか、今日では良くないものの代名詞のように なっている。良くないということの主な理由はプログラムの流れが 見えにくくなる、等のようなのだが、実際のところどの程度のものかは よく分からない。C言語において、例えばループ構文を使わずにすべてを gotoでまかなおうとするとこれはほとんど自明に、確かに大変である。 例えばfor文なら、 for (A;B;C) body というものは、これを形式的に A _continue_for: if (B) goto _break_for; C goto _continue_for; _break_for:; このように変

    2004-10-02
    h-hirai
    h-hirai 2008/07/29
    C言語の継続
  • hatena::get_diary<gnarl>::result - いま流行のFizzBuzzを純粋関数型言語C++で書いてみた

    73行。boost/mplやboost/lambda駆使すれば20行くらいになるかな? なんかあんまり純粋関数な感じしないんだよね微妙。 template<bool cond,typename th,typename el> struct if_; template<typename th,typename el> struct if_<true,th,el> { typedef th result; }; template<typename th,typename el> struct if_<false,th,el> { typedef el result; }; template<int n> struct int_{}; struct fizz {static const char* str;}; struct buzz {static const char* str;}; str

    hatena::get_diary<gnarl>::result - いま流行のFizzBuzzを純粋関数型言語C++で書いてみた
    h-hirai
    h-hirai 2008/07/29
    「何が嬉しいんだ。」w