%%- \documentclass[11pt,a4paper]{article}
%%-
%%- \usepackage{Rd}
\renewcommand{\^}{\code{\char'136}}
\renewcommand{\~}{\code{\char'176}}

\newcommand{\primfun}{{\normalfont\slshape\scshape$\langle$primitive$\rangle$}}

%%- \begin{document}

\subsection{``Which \R\ functions should stay \primfun\ ?''}

\begin{enumerate}
\item In general, all functions should be written using
  \code{.Internal(..)}.

  However, there are exceptions which are fully specified as follows:

\item ``Special functions'' which really are \emph{language} elements,
  however exist as \primfun s in \R:
  \begin{center}\ttfamily
    \begin{tabular}{*{9}{c}}
      \{ & ( & if & for & while & repeat & break & next \\
      return & function & on.exit
    \end{tabular}
  \end{center}


\item Basic \emph{operator}s (i.e. functions, usually \emph{not} called as
  \code{\textsl{fun(a,\dots)}})
  for subsetting, assignment, arithmetic and logic. These are the following
  1--, 2--, and $N$--argument functions
  \begin{center}\ttfamily
    \begin{tabular}{*{8}{p{2em}}}
         &     & [   & [[   & \$   \\
      <- & <<- & [<- & [[<- & \$<- \\ \hline

      +  & -  & *  & /    & \^ & \%\% & \%*\% & \%/\% \\
      <  & <= & == & !=   & >= &  >   \\
      |  & || & \& & \&\& & !
    \end{tabular}
  \end{center}

\item ``Low level'' \underline{0-- and 1--argument} functions shall remain
  \primfun, iff they belong to one of the following groups of functions:

  \begin{enumerate}

  \item Basic mathematical functions with a single argument, i.e.,
    \begin{center}\ttfamily
      \begin{tabular}{lll}
        sign & abs \\
        floor & ceiling \\
        \hline
        sqrt & exp \\
         cos &  sin & tan \\
        acos & asin & atan \\
        cosh & sinh & tanh \\
        acosh & asinh & atanh \\
        \hline
        cumsum & cumprod \\ cummax & cummin \\
        \hline
        Im & Re \\
        Arg & Conj & Mod
      \end{tabular}
    \end{center}

    Note, that \code{log} has \emph{two} arguments, and we will use
    \\
    \code{
      log \SIs\ function(x, base=exp(1)) \\ \hspace*{2em}
              if(missing(base)) .Internal(log(x)) else .Internal(log(x,base))
      }\\
    in order to ensure that \code{log(x=pi, base=2)} is identical to
    \code{log(base=2, x=pi)}.

  \item Functions rarely used outside of ``programming'' (i.e., mostly used
    inside other functions), such as
    \begin{center}\ttfamily
      \begin{tabular}{*{4}{l}}
         nargs & missing \\
        interactive & \code{is.\textsl{xxx}} &
            \multicolumn{2}{p{15em}}{\normalfont\slshape ``xxx'' standing for
              about 30 different notions, e.g.,
              \code{function}, \code{vector},
              \code{numeric}, \ldots} \\
        .Internal & symbol.C & symbol.For \\
        globalenv & pos.to.env & unclass
        %% substitute(expr, env)   has 2 args..
      \end{tabular}
    \end{center}
\pagebreak[3]% is not enough; what a pain...
  \item The programming and session management utilities
    \begin{center}\ttfamily
      \begin{tabular}{*{5}{l}}
        debug & undebug & trace & untrace \\
        browser & proc.time
      \end{tabular}
    \end{center}
  \end{enumerate}

\item The following basic assignment and extractor functions
  \begin{center}\ttfamily
    \begin{tabular}{ll}
      .Alias & environment<- \\
      length & length<- \\
      class  & class<-  \\
        attr & attr<- \\
   attributes& attributes<- \\
      dim    & dim<- \\
    dimnames & dimnames<- \\
    %%-comment & comment<- \\
%% New data.frame code
%%-  levels & levels<- \\
%%-  codes  & codes<- \\
%%-  %%-- the ``['' need to have something in front {Tabular/ ``\\" problem}:
%%-   \ [.data.frame &  [<-.data.frame \\
%%-  {}[[.data.frame & [[<-.data.frame
    \end{tabular}
  \end{center}

\item A few other \underline{$N$-argument} functions shall also remain
  \primfun, for efficiency reasons.
  Care is taken in order to treat named arguments properly:
  \begin{center}\ttfamily
    \begin{tabular}{*{8}{l}}
      :    & \~ & c & list & unlist \\
      call & as.call & expression & substitute \\
      UseMethod & invisible \\
      .C & .Fortran
    \end{tabular}
  \end{center}

\end{enumerate}

%%- \end{document}
