Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Indentation style
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Whitesmiths === The Whitesmiths style, also sometimes termed Wishart style, was originally used in the documentation for the first commercial C compiler, the [[Whitesmiths]] Compiler. It was also popular in the early days of Windows, since it was used in three influential Windows programming books, ''[[Programmer's Guide to Windows]]'' by [[David Durant|Durant]], [[Geta Carlson|Carlson]] & [[Paul Yao|Yao]], ''[[Programming Windows]]'' by [[Charles Petzold|Petzold]], and ''[[Windows 3.0 Power Programming Techniques]]'' by [[Peter Norton|Norton]] & Yao. Whitesmiths, along with [[#Allman style|Allman]], were claimed to have been the most common bracing styles in 1991 by the [[Jargon File]], with roughly equal popularity at the time.<ref name=jargon/><ref name="jargon243">{{cite web |url=http://www.catb.org/~esr/jargon/oldversions/jarg243.txt |title=The Jargon File (Version 2.4.3) |version=2.4.3 |date=23 January 1991 |access-date=14 May 2024}}</ref> This style puts the brace associated with a control statement on the next line, indented. Statements within the braces are indented to the same level as the braces. Like Ratliff style, the closing brace is indented the same as statements within the braces.<ref name="mcconnell" /> <syntaxhighlight lang=c> while (x == y) { something(); something_else(); } final_thing(); </syntaxhighlight> The advantages of this style are similar to those of the [[#Allman style|Allman style]]. Blocks are clearly set apart from control statements. The alignment of the braces with the block emphasizes that the full block is conceptually, and programmatically, one compound statement. Indenting the braces emphasizes that they are subordinate to the control statement. The ending brace no longer lines up with the statement, but instead with the opening brace. An example: <syntaxhighlight lang=c> if (data != NULL && res > 0) { if (!JS_DefineProperty(cx, o, "data", STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)), NULL, NULL, JSPROP_ENUMERATE)) { QUEUE_EXCEPTION("Internal error!"); goto err; } PQfreemem(data); } else if (!JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL), NULL, NULL, JSPROP_ENUMERATE)) { QUEUE_EXCEPTION("Internal error!"); goto err; } </syntaxhighlight> <code>else if</code> are treated as statement, much like the <code>#elif</code> preprocessor statement.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)