Changeset 2352 for trunk/doc/misc/perlCodeConventions.tex
- Timestamp:
- Nov 12, 2004, 12:06:19 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/misc/perlCodeConventions.tex (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/misc/perlCodeConventions.tex
r2351 r2352 1 %%% $Id: perlCodeConventions.tex,v 1. 8 2004-11-12 21:58:22jhoblitt Exp $1 %%% $Id: perlCodeConventions.tex,v 1.9 2004-11-12 22:06:19 jhoblitt Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 165 165 # Copyright (C) 2004 Joshua Hoblitt 166 166 # 167 # $Id: perlCodeConventions.tex,v 1. 8 2004-11-12 21:58:22jhoblitt Exp $167 # $Id: perlCodeConventions.tex,v 1.9 2004-11-12 22:06:19 jhoblitt Exp $ 168 168 169 169 use 5.008005; # optional … … 222 222 # Copyright (C) 2004 Joshua Hoblitt 223 223 # 224 # $Id: perlCodeConventions.tex,v 1. 8 2004-11-12 21:58:22jhoblitt Exp $224 # $Id: perlCodeConventions.tex,v 1.9 2004-11-12 22:06:19 jhoblitt Exp $ 225 225 226 226 package Foo; … … 842 842 \begin{verbatim} 843 843 my @things = qw( foo bar baz ); 844 \end{verbatim} 844 845 \end{itemize} 845 846 … … 1076 1077 \label{SourceExample} 1077 1078 1078 \tbd{Need to include more of the rules, and shorten the example}1079 Here's \file{psBuffer.h}:1080 \begin{verbatim}1081 #if !defined(PS_BUFFER_H) /* here's the insides of psBuffer.h */1082 #define PS_BUFFER_H1083 #define PS_BUFSIZE 128 // Size for I/O buffers1084 1085 typedef struct {1086 char buf[PS_BUFSIZE]; // buffer1087 int n; // number of bytes in buffer1088 } psBuffer;1089 1090 psBuffer *psBufferAlloc(void);1091 void psBufferFree(psBuffer *buf, // buffer to delete1092 int deep); // NOTUSED. Do a deep delete1093 1094 void psBufferAppend(psBuffer *restrict buf, // psBuffer to append to1095 const char *restrict str); // string to add1096 1097 #endif1098 \end{verbatim}1099 1100 1079 And here's the C source; \file{psUtils.h} provides \code{psAlloc/psFree}. 1101 1080 … … 1218 1197 %------------------------------------------------------------------------------ 1219 1198 1220 \section{Departures from Sun Java Coding Standards}1221 1222 Apart from changes required by our use of C99 rather than Java,1223 this document differs from the original Sun-Java standard in1224 two sorts of ways; additions and changes.1225 1226 \subsection{ Additions to the Sun-Java standards}1227 1228 \begin{itemize}1229 \item1230 Naming convention for include files1231 1232 \item1233 Added naming conventions for constructors, destructors, and conversion1234 subroutines.1235 1236 \item1237 Specified that the `output' argument should come \emph{first}.1238 1239 \item1240 Added conventional comments for unused arguments and unreachable1241 statements (conforming to Doxygen's conventions).1242 1243 \item1244 Specified that subroutines taking no arguments should be explicitly1245 specified as \code{(void)} (avoiding complaints on some compilers,1246 e.g. on SGIs).1247 1248 \item1249 Added rules on typedefing structs, and on struct tags.1250 1251 \end{itemize}1252 1253 \subsection{Departures from the Sun-Java standards}1254 1255 \begin{itemize}1256 1257 \item1258 We break lines \emph{after} (not before) an operator.1259 1260 \item1261 We don't specify any special indentation for continued logical1262 expressions within an \code{if} clause.1263 1264 \item1265 Specify that \code{case/break} statements should be indented1266 by half an indent (2 spaces)1267 1268 \item1269 Comments need not be preceeded by a blank line1270 1271 \item1272 The restriction on only declaring variables at the top of blocks (including1273 \code{for} loops has been somewhat relaxed.1274 1275 \item1276 Relaxed the `only one statement per line' rule a little.1277 1278 \item1279 High-precedence binary operators (\code{*}, \code{/}, \code{%} and above)1280 should \emph{not} be surrounded by whitespace.1281 1282 \item1283 The line-length limit has been changed from 80 to 110 characters.1284 1285 \item1286 Relaxed wording to allow parentheses to be omitted when the precedence1287 is well known and unambiguous.1288 1289 \end{itemize}1290 1291 %------------------------------------------------------------------------------1292 1293 \section{How to Achieve This Style in Emacs}1294 \label{dot_emacs}1295 1296 \textit{This section is provided for your convenience; it is, of course,1297 not part of the coding standards.}1298 1299 The easiest way to use these conventions while writing code using1300 emacs is to get \file{panstarrs.el} from \code{cvs} with the command1301 \begin{verbatim}1302 cvs -d poiserver0.ifa.hawaii.edu:/usr/local/cvs/repositories/pan-starrs co Templates1303 \end{verbatim}1304 and then grab \file{Templates/panstarrs.el}. Then add:1305 1306 \begin{verbatim}1307 (load-file "/home/you/Templates/panstarrs.el")1308 (add-to-list 'auto-mode-alist (cons "\\.[ch]$" 'panstarrs-c-mode))1309 \end{verbatim} % $ % match that $ for emacs1310 to your \file{.emacs} file; this will use \code{panstarrs-c-mode}1311 for all \file{.c} and \file{.h} files.1312 1313 If you want to1314 \begin{itemize}1315 \item use C99-style comments (i.e. \code{//} to end of line)1316 \item have your emacs window set to 110 characters wide1317 \item somewhat improve (or spoil?) the handling of re-indenting comments1318 \end{itemize}1319 add one or more of these \code{add-hook} commands to your \file{.emacs} file too:1320 \begin{verbatim}1321 (add-hook 'panstarrs-c-mode-hook 'panstarrs-c99-comments)1322 (add-hook 'panstarrs-c-mode-hook 'panstarrs-set-width)1323 (add-hook 'panstarrs-c-mode-hook1324 '(lambda ()1325 (set (make-variable-buffer-local 'comment-indent-subroutine)1326 'panstarrs-comment-indent)))1327 \end{verbatim}1328 1329 1199 \section{How to Achieve This Style with Astyle} 1330 1200 \label{astyle}
Note:
See TracChangeset
for help on using the changeset viewer.
