(R-lang.info)Computing on the language


Next: System and foreign language interfaces Prev: Object-oriented programming Up: Top
Enter node , (file) or (file)node

6 Computing on the language
***************************

R belongs to a class of programming languages in which subroutines have
the ability to modify or construct other subroutines and evaluate the
result as an integral part of the language itself.  This is similar to
Lisp and Scheme and other languages of the "functional programming"
variety, but in contrast to FORTRAN and the ALGOL family.  The Lisp
family takes this feature to the extreme by the "everything is a list"
paradigm in which there is no distinction between programs and data.

   R presents a friendlier interface to programming than Lisp does, at
least to someone used to mathematical formulas and C-like control
structures, but the engine is really very Lisp-like.  R allows direct
access to parsed expressions and functions and allows you to alter and
subsequently execute them, or create entirely new functions from
scratch.

   There is a number of standard applications of this facility, such as
calculation of analytical derivatives of expressions, or the generation
of polynomial functions from a vector of coefficients.  However, there
are also uses that are much more fundamental to the workings of the
interpreted part of R. Some of these are essential to the reuse of
functions as components in other functions, as the (admittedly not very
pretty) calls to 'model.frame' that are constructed in several modeling
and plotting routines.  Other uses simply allow elegant interfaces to
useful functionality.  As an example, consider the 'curve' function,
which allows you to draw the graph of a function given as an expression
like 'sin(x)' or the facilities for plotting mathematical expressions.

   In this chapter, we give an introduction to the set of facilities
that are available for computing on the language.

Direct manipulation of language objects
Substitutions
More on evaluation
Evaluation of expression objects
Manipulation of function calls
Manipulation of functions

automatically generated by info2www version 1.2.2.9