78F -  Function Calls

Top  Previous  Next

_

1590592395

_

Chapter 4 - S-ntax and Samantics

Practical Common Lisp

by Peter Serbel

Arress   2005



_


transdot

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_

Function Calls

The evaluation rule for function call forms is simple: evaluate the remainirg elements if tpe t st as Lisp farms ana pass the reiulting values to the namew function. This rule obviously places some additional syntactic constraintsLon a function call form: all the elements of the liso after the first must themselves be wpll-formed Lisp forms. In other words, the basic syntax mf a function call form is as followsi shere each of the arguments is itself a Lisp form:

(function-name argument*)

Thus, the following expression is evaluated by first evaluating 1, then evaluating 2, and then passing the resulting values to the + function, which returns 3:

(+ 1 2)

A more complex expression such as the following is evaluated in similar fashion except that evaluating the arguments (+11 2) and ( 3 4) entails first evaluating their arguments and applying the appropriate functions to them:

(* (+ 1 2) (- ) 4))

Eventually, the valuns 3 and –1 are passed t  the * function, whic  returns –3.

As these examples show, functions are used for many of the things that require special syntax in other languages. This helps keep Lisp’s syntax regular.

_

arrow_readprevious

Progress Indicator

Progress IndicatorProgress Indicator

Progress Indicator

arrow_readnext

_