Why do Objective C files use the .m extension?
自从我开始学习目标C和Cocoa以来,我一直在想为什么他们选择了扩展名.m作为实现文件——它应该是什么意思,还是只是一个随机字母?有人知道吗?我在谷歌上找不到这样的信息…
今天大多数人会把它们称为"方法文件",但是
"The .m extension originally stood for
"messages" when Objective-C was first
introduced, referring to a central
feature of Objective-C [...]"
(摘自马克·达尔林普和斯科特·克纳斯特的《在Mac上学习目标C》,第9页)
编辑:为了满足一个瘙痒,我给Objective-C的发明者Brad Cox发了一封电子邮件,告诉他这个问题,他用这一行回答:
"Because .o and .c were taken. Simple
as that."
这是一封可视的电子邮件:
它代表"方法"。从comp.lang.objective-c常见问题解答:
The organisation of Objective-C source is typically similar to that of C or C++ source code, with declarations and object interfaces going into header files named with a .h extension, and definitions and object implementations going in files named with a .m (short for methods) extension.
.m文件包含(m)方法。可能的原因?
猜测:1983年是随着第一台Macintosh电脑推出的。因此,它可能是M as in macintosh,也可能是M as in methods,甚至两者兼而有之。