LoginSignup
6
3

More than 5 years have passed since last update.

Ancient C探訪記:キーワード編

Last updated at Posted at 2017-12-11

おことわり: この記事では「1975年頃のC言語」仕様を解説します。2017年現在のC言語仕様とは異なるため、あなたのC言語ライフには役立たないことを予めご承知おきください。

(本投稿は Ancient C探訪記 シリーズの一部です。)

手始めに、違いが一番分かりやすい「キーワード(keyword)」から見ていきましょう。

Ancient Cのキーワード

"C Reference Manual" §2.3 Keywords より一覧を引用します。今日でもお馴染みのキーワードが並んでいるかと思います:

The following identifiers are reserved for use as keywords, and may not be used otherwise:

int         break
char        continue
float       if
double      else
struct      for
auto        do
extern      while
register    switch
static      case
goto        default
return      entry
sizeof

幻のentryキーワード

リストをよく見ると、一つだけ entry という見慣れないキーワードが混じっています。

The entry keyword is not currently implemented by any compiler but is reserved for future use.

Ancient C時点でも実装は存在せず “将来のために予約” となっていました。StackOverflowでの回答によると、entryは “関数に対して複数のエントリポイントを定義可能とする” ためのキーワードだったようです。

Q: What was the entry keyword mentioned in K&R1?
A: It was reserved to allow functions with multiple, differently-named entry points, but it has been withdrawn.

少々意味を取りづらいですが、return文を用いて関数からの出口を複数記述できるように、ある関数への複数の入り口(entry point)を記述できるようにしたかったのでしょう。SUGEE。

同キーワードはANSI C以降の標準規格には存在しませんから、結局そのままお蔵入りしたようです。当時のCコンパイラでも未実装に終わった様子ですし、構造化プログラミングという観点からもさすがに柔軟性が高すぎると判断されたのでしょう。

標準規格との差分

次は Ancient C 時点では定義されておらず、標準規格(ANSI C、C90)に存在するキーワードを列挙します:

  • unsigned
  • signed
  • short
  • long
  • void
  • const
  • volatile
  • typedef
  • enum
  • union

いかがでしょう。感想は人それぞれだとは思いますが、意外なキーワードがリストにあるかもしれませんね。

適当に明日以降につづきます。

6
3
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3