Why do Objective-C files use the .m extension?

我的未来我决定 提交于 2019-11-26 22:29:59

问题


Since I started learning Objective-C and Cocoa, I've been wondering why they have chosen the extension .m for the implementation files - was it supposed to mean something, or was it just a random letter?


回答1:


Today most people would refer to them as "method files", but

"The .m extension originally stood for "messages" when Objective-C was first introduced, referring to a central feature of Objective-C [...]"

(from the book "Learn Objective-C on the Mac" by Mark Dalrymple and Scott Knaster, page 9)

EDIT: To satisfy an itch I emailed Brad Cox, the inventor of Objective-C, about the question and he answered with this single line:

"Because .o and .c were taken. Simple as that."

Here's the email as visual proof:




回答2:


It stands for "methods". From the comp.lang.objective-C FAQ:

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.




回答3:


.m files contain the (m)ethods. Possible reason?




回答4:


Wild guess: 1983 was ObjectC introduced along with the first Macintosh computer... . So it might be m as in macintosh or m as in methods or even both.



来源:https://stackoverflow.com/questions/652186/why-do-objective-c-files-use-the-m-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!