user3144191
user3144191

Reputation: 31

Terminology: do variables and symbols have a value or are they bound to a value?

The arguments of a function, I mean the x and the y as in

(defun my-function (x y ) body) 

are sometimes also called the local variables or the local parameters or the formal parameters or even the parameters. Are all these terminologies really correct in Lisp? Is another terminology more suited?

Furthermore one says that the arguments of a functions are bound to the values of the arguments of the function that is calling. Is this terminology "bound to" correct? Or do we have to say that they will "have the value" of the arguments of the function called?

And does one say that a global symbol is "bound to a value" or "has the value"? I read in a book that this is a cause of enormous confusion. In that book it is suggested that the words "bound to" should not be used for global symbols, but should only be used for the arguments of a function. But on the other hand, the build in function boundp like in

(boundp 'x)) 

is used in Lisp also for global symbols. This would suggest that symbols do not "have a value" but are "bound to a value"?

Upvotes: 3

Views: 71

Answers (1)

Rainer Joswig
Rainer Joswig

Reputation: 139261

Common Lisp uses this terminology:

A function has a defined list of parameters.

Evaluation of a function call adds a binding of each parameter with the corresponding value from the arguments to the current lexical environment.

Global variables have a binding in the global environment.

Reference

See Common Lisp HyperSpec (a HTML variant of the ANSI Common Lisp standard), and there the chapters on Evaluation/Compilation and the Glossary. That document describes the terminology, useful for Common Lisp. Other Lisp dialects (Emacs Lisp, ISLisp, Visual Lisp, ...) may have different terminology.

Example

(defun foo (a b)
  (bar a b a b))

Above function explained in the comments:

(defun foo        ; <- the name of the global function is foo

           (a b)  ; <- the list of parameters of the function foo

                  ; <- in the body, a and b are bound

                  ; in the body there is one function call form
  (bar            ; <- the function bar gets called
       a b a b)   ; <- the arguments to be evaluated
  )

Upvotes: 7

Related Questions