<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\newcommand{\primfun}{{\normalfont\slshape\scshape$\langle$primitive$\rangle$}}

\section{``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
\renewcommand{\{}{\code{\char'173}}
    \begin{tabular}{*{9}{c}}
      \{ &amp; ( &amp; if &amp; for &amp; while &amp; repeat &amp; break &amp; next \\
      return &amp; function &amp; 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
    \renewcommand{\^}{\code{\char'136}}
    \begin{tabular}{*{8}{p{2em}}}
         &amp;     &amp; [   &amp; [[   &amp; \$   \\
      &lt;- &amp; &lt;&lt;- &amp; [&lt;- &amp; [[&lt;- &amp; \$&lt;- \\ \hline

      +  &amp; -  &amp; *  &amp; /    &amp; \^ &amp; \%\% &amp; \%*\% &amp; \%/\% \\
      &lt;  &amp; &lt;= &amp; == &amp; !=   &amp; &gt;= &amp;  &gt;   \\
      |  &amp; || &amp; \&amp; &amp; \&amp;\&amp; &amp; !
    \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 &amp; abs \\
        floor &amp; ceiling \\
        \hline
        sqrt &amp; exp \\
         cos &amp;  sin &amp; tan \\
        acos &amp; asin &amp; atan \\
        cosh &amp; sinh &amp; tanh \\
        acosh &amp; asinh &amp; atanh \\
        \hline
        cumsum &amp; cumprod \\ cummax &amp; cummin \\
        \hline
        Im &amp; Re \\
        Arg &amp; Conj &amp; 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 &amp; missing \\
        interactive &amp; \code{is.\textsl{xxx}} &amp;
            \multicolumn{2}{p{15em}}{\normalfont\slshape ``xxx'' standing for
              almost 30 different notions, e.g.,
              \code{function}, \code{vector},
              \code{numeric}, \ldots} \\
        .Primitive &amp; .Internal &amp; .External \\
        symbol.C &amp; symbol.For \\
        globalenv &amp; pos.to.env &amp; 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 &amp; undebug &amp; trace &amp; untrace \\
        browser &amp; proc.time
      \end{tabular}
    \end{center}
  \end{enumerate}

\item The following basic assignment and extractor functions
  \begin{center}\ttfamily
    \begin{tabular}{ll}
      .Alias &amp; environment&lt;- \\
      length &amp; length&lt;- \\
      class  &amp; class&lt;-  \\
        attr &amp; attr&lt;- \\
   attributes&amp; attributes&lt;- \\
      dim    &amp; dim&lt;- \\
    dimnames &amp; dimnames&lt;- \\
    %%-comment &amp; comment&lt;- \\
%% New data.frame code
%%-  levels &amp; levels&lt;- \\
%%-  codes  &amp; codes&lt;- \\
%%-  %%-- the ``['' need to have something in front {Tabular/ ``\\" problem}:
%%-   \ [.data.frame &amp;  [&lt;-.data.frame \\
%%-  {}[[.data.frame &amp; [[&lt;-.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
    \renewcommand{\~}{\code{\char'176}}
    \begin{tabular}{*{8}{l}}
      :    &amp; \~ &amp; c &amp; list &amp; unlist \\
      call &amp; as.call &amp; expression &amp; substitute \\
      UseMethod &amp; invisible \\
      .C &amp; .Fortran &amp; .Call
    \end{tabular}
  \end{center}

\end{enumerate}
</pre></body></html>