_Underscores in Function Names

醉酒当歌 提交于 2019-11-28 08:15:34

In C++ world, member names that start with underscore are reserved for use by compiler (or low level STL like API) developers. It's not prohibited by compilers in any way, but that's the tradition.

This wiki link is quite informative on underscore.

I cannot tell you the origin of this convention. My guess is, since the underscore is the only non-alphanumeric character allowed in identifiers in most programming languages, it is natural to chose it as a prefix for private members.

In Python, prefixing names with an underscore is more than just a convention: Symbols starting with an underscore are not imported by default when importing "everything" from a module, therefore the underscore indicates "private" / "internal usage".

underscore ( _ ) stands for a private / protected function or variable.

Don't know WHO actually came up with it, but I know it is "supported" by Zend ( and the Zend coding standards ).

edit : http://framework.zend.com/manual/en/coding-standard.naming-conventions.html

-> section B.3.4 -> paragraph 2

I first saw it when coding C++. Marking member variables with "m_" prefix was commonly done.

I prefer to not use any of that when I write Java. I make member variables clear using "this".

I've seen underscore used as private functions and I've seen seen underscore as global functions. Also underscore is used to denote global variables within PHP itself.

$_POST $_GET $_SESSION etc..

It's just a naming convention so I'd ask the author, if he's around.

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