ABSTRACT

This chapter discusses the S language, its evaluator, and some of the key S functions. The grammar used by the standard S parser is presented as a set of syntactic rules. The semantics of the S evaluator are discussed, using a model evaluator written in S. The evaluator uses the mode of an expression to decide how to evaluate it. Evaluation is highly recursive, so that evaluating an expression will typically involve calling the evaluator again for elements of that expression. Function Calls: Mode call is the most important language mode, and it drives the mechanism of the evaluator. It is evaluated as follows: the evaluator finds the definition of the function called, creates a new frame by matching the call and the definition, evaluates the body of the function by invoking Eval recursively, and returns the result. Evaluating a name amounts to finding the corresponding object and, if the object is an unevaluated argument to current frame, evaluating it.