From 4b6096f65e6e134a05dc4316dde2def760cf2f6c Mon Sep 17 00:00:00 2001 From: ReneSac Date: Sat, 29 Mar 2014 16:10:21 -0700 Subject: [PATCH] Updated Whitespace FAQ (markdown) --- Whitespace-FAQ.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Whitespace-FAQ.md b/Whitespace-FAQ.md index 691819f..f1ff8a9 100644 --- a/Whitespace-FAQ.md +++ b/Whitespace-FAQ.md @@ -4,9 +4,9 @@ Virtually all programming languages use whitespace as part of their syntax. Many # New Lines -Most statements have only one line. With languages whose lines are delimited by semicolons, the programmer pays a tax every line, just so that multiline statements can be used. But as presented below, Nimrod lets you use multiline statements most of the time w/o requiring this semicolon tax. +Most statements have only one line, and are followed by a line break. With languages whose lines are delimited by semicolons, the programmer pays a tax every line, just so that multiline statements can be used. But as presented below, Nimrod lets you use multiline statements most of the time w/o requiring this semicolon tax. -Really long lines that must be broken are bad style, but often unavoidable. In those cases, Nimrod provides many implicit continuation . The rule of thumb is 80 to 120 characters maximum per line. If none of those things occurs naturally on your line, you can always add a parenthesis around it all. Two characters in those exceedingly rare situations, instead of one character every line. +Really long lines that must be broken are bad style, but often unavoidable. In those cases, Nimrod provides many implicit continuation . The rule of thumb is that after a `,`, unary or binary operator and `(` `[` `{` you can safely put a line break and continue the statement in the following line. If none of those things occurs naturally, you can always add a parenthesis. Two characters in those exceedingly rare situations, instead of one character every line. After a continuation, the code can be positioned quite freely. The only rule is that the continuing line must be indented at least one level above the first line. @@ -15,15 +15,17 @@ For example, all the following nimrod code is valid: ```nimrod someReallyLongProc(withMany, commands, - that may be broken, - in many lines) + that, may, be, broken, + in many, lines) var x = 2 + - 2 -var y = - [ - 1, 2, 3 + 2 + +const DeBruijnNumbersTable: array[32, int8] = + [ + 0'i8, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, + 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 ] ``` @@ -43,7 +45,7 @@ else ### Tabs vs Spaces -This is a non-issue in Nimrod, as only spaces are accepted as an indentation character - a syntax error will be thrown if the compiler detects tabs being used for indentation (though this can be worked around by using a (link here w/ text "syntax filter"). However, languages that allow both of them to be mixed are dangerous. Some languages, like python 2 by default (fixed on python 3), tries to convert a tab to a certain number of spaces, and thus an indentation error introduced by mixing tabs and spaces will only be detected as a run-time failure. Other languages, that ignores any type of indentation, will generate code that behaves differently than it looks at first sight when using an editor with different tab-stops configuration. This can hide/introduce bugs, like in the previous C/C++ example. +This is a non-issue in Nimrod, as only spaces are accepted as an indentation character --- a syntax error will be thrown if the compiler detects tabs being used for indentation (though this can be worked around by using a (link here w/ text "syntax filter"). However, languages that allow both of them to be mixed are dangerous. Some languages, like python 2 by default (fixed on python 3), tries to convert a tab to a certain number of spaces, and thus an indentation error introduced by mixing tabs and spaces will only be detected as a run-time failure. Other languages, that ignores any type of indentation, will generate code that behaves differently than it looks at first sight when using an editor with different tab-stops configuration. This can hide/introduce bugs, like in the previous C/C++ example. ### Sharing code