[Next] [Previous] [Up] [Top] [Contents] [Index]

Interacting with the Listener

Evaluating expressions

When you type a complete expression in the Listener and press Return, Macintosh Common Lisp immediately evaluates the expression and returns the result.

? (+ 10 20 30)
60
? (aref #(a b c d) 0)
A
? "Simple String"
"Simple String"

Every kind of Lisp expression has its own rules for evaluation. The first two examples given above are function calls, which evaluate to the result of calling the function on the arguments. The third example is a string constant. String constants (like other constants) evaluate to themselves.

Figure 2-3 A simple Listener interaction

You can also type more complex expressions into the Listener. Many expressions will contain nested subexpressions. It is also common to test out function and class definitions in the Listener.

? (+ 25 (* 10 10) (* 5 5))
150
? (defun factorial (n)
    (if (= n 0)
      1
      (* n (factorial (- n 1)))))
 FACTORIAL
? (factorial 10)
3628800

When an evaluation is in progress, the About Macintosh Common Lisp command on the Apple menu is preceded by a diamond and the Listener minibuffer shows the word "busy."


Gettmg Started with MCL - 19 OCT 1996
[Next] [Previous] [Up] [Top] [Contents] [Index]

Generated with Harlequin WebMaker