ときどきの雑記帖″

最新ページへのリンク
目次ページへのリンク

一つ前へ 2014年8月(下旬)
一つ後へ 2014年9月(中旬)

ホームへ

2014年09月10日

■_

Elixir と swift が 1.0 と。

■_

2014年09月09日

■_

お、もうすぐ出るのか 湖底の城 呉越春秋 第五巻
湖底の城 呉越春秋 第五巻

■_

2014年09月08日

■_

「第一優先」ってそれなりに使われている言い回しなんですかね。 なんかもやもやするんですが。第二~以降を見たことないしw

月曜日朝のコンビニの雑誌コーナーでジャンプを熱心に立ち読みしている高校生に 道を塞がれて新学期を実感するなど。

ヴォルフスムントの6巻が来月発売予定らしい。

■_

久しぶりにInfoQから

C++14登場 -その新機能
C++14の主要機能は3つのグループに分類できる。ラムダ関数,constexpr,そして型推論だ。

ラムダ関数

C++14のジェネリックラムダは次のように記述可能だ。

auto lambda = [](auto x, auto y) {return x + y;};

C++11のラムダパラメータでは,次のように,ラムダパラメータの型を明確に宣言する必要があった。

int lambda = [](int x, int y) {return x + y;};

さらに新標準のstd::move関数を使えば,オブジェクトをコピーや参照する代わりに移動することによって,ラムダ式内の
変数をキャプチャすることができる。

(略)

型推論

C++11ではラムダ式のみであった戻り値の型推論が,C++14ではすべての関数で可能になる。

auto DeducedReturnTypeFunction();

ただしC++14は強い型付け言語であるため,いくつかの制限を考慮に入れなければならない。

    関数の実装に複数のreturn文がある場合,それらはすべて同じ型を推論するものでなければならない。
    戻り値型の推論は前方宣言でも使用可能だが,その関数が使用されるよりも前に,変換ユニットが関数宣言を使用できることが必要だ。
    戻り値の型推論は再帰関数でも使用可能だが,戻り値の型を推論できるように,再帰呼び出しよりも前に少なくともひとつのreturn文がなくてはならない。

ここで「型推論」という用語が出ているのだけど、これ原文では (type inference ではなく) type deducation を使っている。 deducation という単語の意味からすると「型推論」でも悪くないような気もするのだけど、 そーすると type inference と同じ訳語になっちゃってまずいんじゃなかろうか。 というのが一つ。 もう一つはこの記事とは直接関係ないけど、 type inference と type deducation は 同じものなのか違うものなのか。 前者ならなぜわざわざ違う用語を採用したのか。 後者なら具体的にどう違うのか等々。

C++14 Is Here: Summary of New Features

Major C++14 features can be grouped in three areas: lambda functions, constexpr, and type deduction.

Lambda functions

C++14 generic lambdas make it possible to write:

  auto lambda = [](auto x, auto y) {return x + y;};

On the other hand, C++11 requires that lambda parameters be declared with concrete types, e.g:

  auto lambda = [](int x, int y) {return x + y;};

Furthermore, the new standard std::move function can be used to capture a variable in a lambda expression by
moving the object instead of copying or referencing it:

  std::unique_ptr ptr(new int(10));
  auto lambda = [value = std::move(ptr)] {return *value;};

(略)

Type deduction

C++14 allows return type deduction for all functions, thus extending C++11 that only allows it for lambda functions:

auto DeducedReturnTypeFunction();

Since C++14 is a strongly-typed language, a few restrictions shall be taken into account:

    If a function's implementation has multiple return statements, they must deduce the same type.
    Return type deduction can be used in forward declarations, but the function definitions must be available to the translation unit that uses them before they can be used.
    Return type deduction can be used in recursive functions, but the recursive call must be preceded by at least one return statement allowing to deduce the return type.

Another improvement to type deduction brought by C++14 is the decltype(auto) syntax, which allows to compute the type of a given expression using the same mechanism as auto. Both auto and decltype were already present in C++11, but they used different mechanisms to deduce types that could end up in producing different results.

で、 On the other hand, C++11 requires that lambda parameters be declared with concrete types, e.g:C++11のラムダパラメータでは,次のように,ラムダパラメータの型を明確に宣言する必要があった。 はないんじゃないかなあ。 最初の「ラムダパラメータ」がどこから湧いて出たのかわかんないし、 「concrete」が訳から抜け落ちちゃってる。 ん、「明確に」?

Scalaの今後

■_

2014年09月07日

■_

歴史群像最新号の特集記事が良かった。 数字そのものは他の(きちんとした)資料から持ってきたものだけど、 太平洋戦争での空母戦(珊瑚海海戦、ミッドウェイ海戦、南太平洋海戦、第二次ソロモン海戦、マリアナ沖海戦) についての両軍の航空攻撃の状況(発艦した機数/会敵に成功した機数/攻撃できた機数/爆弾・魚雷の命中数)が 書かれていて、特にミッドウェイなんか日本側が先制攻撃食らってどうにもならなかったというのがはっきりわかる。 歴史群像 2014年 10月号 [雑誌]
歴史群像 2014年 10月号 [雑誌]

■_

2014年09月06日

■_

2014年09月05日

■_

2014年09月04日

■_

隣の部署にインターンシップの人が来たらしい。

■_

2014年09月03日

■_

人の振り見て我が振り直せ的な事案

■_

2014年09月02日

■_

やはり大きな油絵はいいすな (小さいのも別の良さがあるけど)

■_

2014年09月01日

■_

あるアセンブリコード(X64)で、je, pn ラベル みたいなのを見かけたんだけどなんだこれ。

■_

■_

今週はまたgdgdになる予定。


一つ前へ 2014年8月(下旬)
一つ後へ 2014年9月(中旬)

ホームへ


リンクはご自由にどうぞ

メールの宛先はこちらkbk AT kt DOT rim DOT or DOT jp