diff options
Diffstat (limited to 'Master/tlpkg/doc/coding-style.txt')
-rw-r--r-- | Master/tlpkg/doc/coding-style.txt | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Master/tlpkg/doc/coding-style.txt b/Master/tlpkg/doc/coding-style.txt index 0cf1a022b87..6a98ecc77a8 100644 --- a/Master/tlpkg/doc/coding-style.txt +++ b/Master/tlpkg/doc/coding-style.txt @@ -23,6 +23,13 @@ This avoids the temptation to put an ever-growing amount of code at the top level. It is better to have the top-level code inside a subroutine. +* The Perl "unless" keyword is cute but mind-bending. Use "if !" instead. + + +* Use "/" as the delimiter of first choice for regular expressions. When +the regex includes a /, use ",". When it includes both "/" and ",", use "!". + + * In the absence of prototypes, try to order routines in a given file top-down rather than bottom-up. So main would come first. @@ -32,9 +39,6 @@ Put a space between arguments of function calls. Karl puts a space before the ( of function calls but no one else does :). -* The Perl "unless" keyword is cute but mind-bending. Use "if !" instead. - - * Handle subroutine arguments like this: sub foo @@ -43,14 +47,14 @@ sub foo ... } -Always use this, vs. shift, even when there is only one argument. It -takes up only one line, which is good. And if the number of arguments -to the function changes, text changes are minimized. +Use this in preference to `shift' even when there is only one argument. +It takes up only one line, which is good. And if the number of +arguments to the function changes, text changes are minimized. * It looks strange to write hash keys as if they were keywords (although it is certainly common Perl practice to do so). Instead, write them as -strings +strings: my $foo = $h->{"key"}; for a reminder that these are not keywords or subroutine names. @@ -69,7 +73,7 @@ not Perl keywords. * Similarly, Perl lets you omit parentheses around function calls and/or primitives in many situations. As a rule, don't do this. It is far clearer to use parens when there's a function call. Exceptions for -these primitives: exists, defined, print (and relatives). +these primitives: exists, defined, print and its relatives. * The above is essentially the recommendation of the GNU coding standards @@ -78,7 +82,7 @@ standards' recommendation of putting braces on lines by themselves, thus eating up precious vertical space. Do not do that. -* Exporting symbols and keeping namespaces clean. +* Exporting symbols and keeping namespaces clean: In general, the only things which should be in @EXPORT are those which are needed nearly universally, such as debug and log. Barewords |