All Manuals > LispWorks IDE User Guide > 22 The Listener

NextPrevUpTopContentsIndex

22.2 Evaluating simple forms

  1. Type the number 12 at the prompt, and press Return.
  2. In general, assume that you should press Return after typing something at the prompt, and that you should type at the current prompt (that is, the one at the bottom of the screen). In fact, the latter is not always necessary; Execute mode describes how to move the cursor to different places, and thus you may not always be on the current prompt.

    Any Common Lisp form entered at the prompt is evaluated and its results are printed immediately below in the Listener.

    When Common Lisp evaluates a number, the result is the number itself, and so 12 is printed out:

    PROMPT >
     12
    12
     
    PROMPT >
     

    When results are printed in the Listener, they start on the line following the last line of input. The 12 has been printed immediately below the first prompt, and below that, another prompt has been printed.

  3. Type * at the current prompt.
  4. PROMPT >
     *
    12
     
    PROMPT >
    

    The variable * always has as its value the result of the previous expression; in this case, 12, which was the result of the expression typed at the first prompt. For a full description, see the Common Lisp HyperSpec. This is an HTML version of the ANSI Common Lisp standard which is supplied with LispWorks.

  5. Type (setq val 12) at the current prompt.
  6. PROMPT >
     (setq val 12)
    12
     
    PROMPT >
    

    The expression sets the variable val to 12. The result of evaluating the form is the value to which val has been set, and thus the Listener prints 12 below the form typed at the prompt.

    This is exactly the same behavior as before, when you typed a number it was evaluated and the result printed in the Listener. What is different this time, of course, is that Lisp has been told to "remember" that 12 is associated with val.

  7. Type val.
  8. The form is evaluated and 12 is printed below it.

  9. Type (+ val val val).
  10. The form, which computes the sum of three vals, is evaluated, and 36 is printed below it.


LispWorks IDE User Guide (Unix version) - 12 Feb 2015

NextPrevUpTopContentsIndex