程序语言中花括号的风格列举
2011-08-01 15:23
190 查看
K&R style -- Named after Kernighan & Ritchie, because the examples
in K&R are formatted this way. Also called `kernel style' because the
Unix kernel is written in it, and the `One True Brace Style' (abbrev.
1TBS) by its partisans. In C code, the body is typically indented by
eight spaces (or one tab) per level, as shown here. Four spaces are
occasionally seen in C, but in C++ and Java four tends to be the rule
rather than the exception.
if () {
Allman style -- Named for Eric Allman, a Berkeley hacker who wrote a
lot of the BSD utilities in it (it is sometimes called `BSD style').
Resembles normal indent style in Pascal and Algol. It is the only style
other than K&R in widespread use among Java programmers. Basic indent per level shown here is eight spaces, but four (or sometimes three)
spaces are generally preferred by C++ and Java programmers.
if ()
{
Whitesmiths style -- popularized by the examples that came with
Whitesmiths C, an early commercial C compiler. Basic indent per level
shown here is eight spaces, but four spaces are occasionally seen.
if ()
{
GNU style -- Used throughout GNU EMACS and the Free Software
Foundation code, and just about nowhere else. Indents are always four
spaces per level, with `{' and `' halfway between the outer and inner
indent levels.
if ()
{
似乎写C++的程序员喜欢用Allman style,而写java的程序员用K&R个人比较推荐Allman style
in K&R are formatted this way. Also called `kernel style' because the
Unix kernel is written in it, and the `One True Brace Style' (abbrev.
1TBS) by its partisans. In C code, the body is typically indented by
eight spaces (or one tab) per level, as shown here. Four spaces are
occasionally seen in C, but in C++ and Java four tends to be the rule
rather than the exception.
if () {
Allman style -- Named for Eric Allman, a Berkeley hacker who wrote a
lot of the BSD utilities in it (it is sometimes called `BSD style').
Resembles normal indent style in Pascal and Algol. It is the only style
other than K&R in widespread use among Java programmers. Basic indent per level shown here is eight spaces, but four (or sometimes three)
spaces are generally preferred by C++ and Java programmers.
if ()
{
Whitesmiths style -- popularized by the examples that came with
Whitesmiths C, an early commercial C compiler. Basic indent per level
shown here is eight spaces, but four spaces are occasionally seen.
if ()
{
GNU style -- Used throughout GNU EMACS and the Free Software
Foundation code, and just about nowhere else. Indents are always four
spaces per level, with `{' and `' halfway between the outer and inner
indent levels.
if ()
{
似乎写C++的程序员喜欢用Allman style,而写java的程序员用K&R个人比较推荐Allman style
相关文章推荐
- 你知道的,javascript语言的执行环境是"单线程模式",这种模式的好处是实现起来比较简单,执行环境相对单纯;坏处是只要有一个任务耗时很长,后面的任务都必须排队等着,会拖延整个程序的执行,因此很多时候需要进行“异步模式”,请列举js异步编程的方法。
- 浅谈代码风格与语言细节理解对程序的影响
- 从Alexander Egyed的论文看程序语言和软件工程的论文写作风格差异
- C语言精华记录——捌(预处理、程序调试、编程风格)
- 黑马程序员——OC基础学习(一)---第一个OC语言程序和面向对象编程的基本认识
- C语言学习历程(六)几个有趣的循环和关键字的小程序
- [iphone]如何发布多语言,程序本地化
- 用 C 语言编写 Windows 服务程序的五个步骤
- C#语言构造蜘蛛程序
- 如何掌握程序语言 (2012-05-25 14:19:58)
- 在 Ubuntu 中给你的照片加上 Instagram 风格的滤镜程序
- 51单片机汇编语言--延时程序的延时时间
- Google Trends:哪种程序语言最受关注
- [汇编语言]-第四章第1个程序
- 编写一个程序,它从标准输入读取C源代码,并验证所有的花括号都正确的成对出现。
- MFC 多语言切换 和 程序重启
- 我是这样学习Linux下C语言编程的-把程序输出信息加到系统日志里去
- 怎样编写支持多国语言的程序, 让它能够根据所运行的操作系统自动显示相应的文字。
- 在程序增加多语言功能
- 在 WinForm/WPF 下制作 Google Material Design 风格程序