Rev 5200 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\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}}\{ & ( & 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 following1--, 2--, and $N$--argument functions\begin{center}\ttfamily\renewcommand{\^}{\code{\char'136}}\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 \\\hlinesqrt & exp \\cos & sin & tan \\acos & asin & atan \\cosh & sinh & tanh \\acosh & asinh & atanh \\\hlinecumsum & cumprod \\ cummax & cummin \\\hlineIm & 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 usedinside 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 foralmost 30 different notions, e.g.,\code{function}, \code{vector},\code{numeric}, \ldots} \\.Primitive & .Internal & .External \\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\renewcommand{\~}{\code{\char'176}}\begin{tabular}{*{8}{l}}: & \~ & c & list & unlist \\call & as.call & expression & substitute \\UseMethod & invisible \\.C & .Fortran & .Call\end{tabular}\end{center}\end{enumerate}