IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2594


Ignore:
Timestamp:
Dec 1, 2004, 6:17:05 PM (22 years ago)
Author:
jhoblitt
Message:

misc corrections
add misc omitted sections
fix examples

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/misc/perlCodeConventions.tex

    r2591 r2594  
    1 %%% $Id: perlCodeConventions.tex,v 1.42 2004-12-01 22:34:22 jhoblitt Exp $
     1%%% $Id: perlCodeConventions.tex,v 1.43 2004-12-02 04:17:05 jhoblitt Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    5454This document is derived from the Pan-STARRS IPP C Code Standards document
    5555(PSDC 430-004), which is derived from the Sun Microsystems Java language coding
    56 standards presented in the Java Language Specification
    57 
    58 (\code{http://java.sun.com/docs/books/jls/index.html}).
     56standards presented in the Java Language Specification\footnote{The Java
     57Language Specification - http://java.sun.com/docs/books/jls/index.html}.
    5958
    6059\begin{verbatim}
     
    8079common with Perl programmers.  Instead, it is an attempt to make the C and Perl
    8180coding styles as consistent as is reasonably feasible within the Pan-STARRS
    82 project.  This document only contains brief discussion of Perl's
     81project.  This document contains only a brief discussion of Perl's
    8382Object-Oriented features and none of it's more advanced features.
    8483
     
    129128\hline
    130129\file{Makefile.PL}&
    131 The preferred name for the file that invokes a ``build'' process.  Typically
    132 this calls \code{ExtUtils::MakeMaker} or \code{Module::Build} setup the the
    133 necessary files to install a module or compile Swig generated C code.\\
     130The preferred name for a file that invokes a ``build'' process.  Typically this
     131calls \code{ExtUtils::MakeMaker} or \code{Module::Build} setup the the
     132necessary files to build and install a module or compile Swig generated C
     133code.\\
    134134\end{tabular}
    135135\end{center}
     
    178178not allowed).  Where \code(requirement = revision + version / 1000 + subversion
    179179/ 1\_000\_000).  e.g. A minimum requirement of \code{perl} 5.8.5 would be
    180 expressed as \code{use 5.008005}
     180expressed as \code{use 5.008005}.
    181181
    182182\item
     
    226226not allowed).  Where \code(requirement = revision + version / 1000 + subversion
    227227/ 1\_000\_000).  e.g. A minimum requirement of \code{perl} 5.8.5 would be
    228 expressed as \code{use 5.008005}
     228expressed as \code{use 5.008005}.
    229229
    230230\item
     
    268268\label{pod}
    269269
    270 This is the format for documentation in a \code{.pod} file that should
    271 accompany a module.
     270Pod files that accompany a module should have the following order:
     271
     272\begin{itemize}
     273\item
     274A \code{pod} command.
     275
     276\item
     277A \code{NAME} section.
     278
     279\item
     280A \code{SYNOPSIS} section.
     281
     282\item
     283A \code{DESCRIPTION} section.
     284
     285\item
     286A \code{USAGE} section.
     287
     288\item
     289A \code{DEVELOPER NOTES} section.
     290
     291\item
     292A \code{CREDITS} section.
     293
     294\item
     295A \code{SUPPORT} section.
     296
     297\item
     298A \code{AUTHOR} section.
     299
     300\item
     301A \code{COPYRIGHT} section.
     302
     303\item
     304A \code{SEE ALSO} section.
     305
     306\item
     307A \code{cut} command.
     308\end{itemize}
    272309
    273310For an example of a properly organized Pod, see Pod File Example
     
    334371
    335372\begin{verbatim}
    336     $longName1 = $longName2*($longName3 + $longName4 - $longName5) +
    337         4*$longname6;                   # PREFER
     373    $longName1 = $longName2 * ($longName3 + $longName4 - $longName5) +
     374        4 * $longName6;                   # PREFER
    338375   
    339     $longName1 = $longName2*($longName3 + $longName4 -
    340                            $longName5) + 4*$longname6; # AVOID
     376    $longName1 = $longName2 * ($longName3 + $longName4 -
     377                           $longName5) + 4 * $longName6; # AVOID
    341378\end{verbatim}
    342379
     
    373410\end{verbatim}
    374411
    375 When deactivating 3 or more lines of code an \code{if} statement should be used
    376 with a false boolean value.  The opening and closing of the \code{if} statement
    377 should be nested to the same depth as the surrounding code and the deactivated
    378 section should be indented.
     412When deactivating 3 or more lines of code an embedded Pod statement should be
     413used.  The opening statement should be \code{=for off} and the closing
     414statement should be \code{=cut}.  The deactivated section should remain nested
     415to the same depth as the surrounding code.
    379416
    380417Example of deactivating multiple lines of code.
    381418
    382419\begin{verbatim}
    383     if (0) {
    384         if ($foo) {
    385             print("foo");
    386         }
    387     }
     420    =for off
     421    if ($foo) {
     422        print("foo");
     423    }
     424    =cut
    388425\end{verbatim}
    389426
     
    425462
    426463Short comments can appear on a single line indented to the level of the code
    427 that follows.  The comment should appear above the code that it is describe and
    428 must have a space between the \code{#} and the first text.
     464that follows.  The comment should appear above the code that it is describing
     465and must have a space between the \code{#} and the first text.
    429466
    430467Example of a single-line comment.
     
    512549\end{verbatim}
    513550
    514 Do not put different types on the same line.  Example:
     551Do not combine different types in the same declaration.  Example:
    515552
    516553\begin{verbatim}
     
    659696
    660697\item
    661 Closing brace \CODE.}. starts a line by itself.  Null statement should have the
    662 closing brace immediately after the opening brace.  e.g. \CODE.{}.
     698Closing brace \CODE.}. starts a line by itself.
    663699
    664700\item
     
    750786\subsection{if, if-else, if-elsif-else Statements}
    751787
    752 \code{if} statements must always use braces \{\} around statements and parentheses
    753 () around conditionals.
     788\code{if} statements must always use parentheses \code{()} around conditionals.
    754789
    755790The \code{if-else} class of statements should have the following form:
     
    865900\end{verbatim}
    866901
     902\subsection{Blocks}
     903
     904The contense of a block should be idented one level.
     905
     906\begin{verbatim}
     907    $foo = foobar($baz);
     908    {
     909        my $bat = fooBaz();
     910        ...
     911    }
     912\end{verbatim}
     913
    867914
    868915%------------------------------------------------------------------------------
     
    949996\begin{itemize}
    950997\item
    951 A dereferencing or method call should not have any blank spaces around the
    952 \code{->} operator.
     998A variable dereference or method call should not have any blank spaces around
     999the \code{->} operator.
    9531000
    9541001\begin{verbatim}
     
    9581005
    9591006\end{itemize}
     1007
     1008
    9601009%------------------------------------------------------------------------------
    9611010
     
    10511100Constants &
    10521101
    1053 Constant names should be in all capital letters and highly descriptive.  The
    1054 \code{constant} pragma should be used to declare constants.
    1055 \emph{``constants'' created this way can not be interpolated inside of double
    1056 quoted strings.}
     1102Constant names should be in all capital letters and highly descriptive.
    10571103
    10581104&
     
    11191165in a \code{for} loop as counter values. 
    11201166
     1167The \code{constant} pragma should be used to declare constants.
     1168\emph{``constants'' created this way can not be interpolated inside of double
     1169quoted strings.}
     1170
     1171See the \code{constant} module's Pod for further details.
     1172
    11211173\subsection{Variable Assignments}
    11221174
     
    11381190\end{verbatim}
    11391191
    1140 should be written as
     1192should be written as:
    11411193
    11421194\begin{verbatim}
Note: See TracChangeset for help on using the changeset viewer.