Node:rotate-yk-ptr body, Previous:Understanding rotate-yk-ptr, Up:rotate-yank-pointer

B.1.1 The Body of rotate-yank-pointer

The body of rotate-yank-pointer is a let expression and the body of the let expression is an if expression.

The purpose of the if expression is to find out whether there is anything in the kill ring. If the kill ring is empty, the error function stops evaluation of the function and prints a message in the echo area. On the other hand, if the kill ring has something in it, the work of the function is done.

Here is the if-part and then-part of the if expression:

(if (zerop length)                      ; if-part
    (error "Kill ring is empty")        ; then-part

If there is not anything in the kill ring, its length must be zero and an error message sent to the user: Kill ring is empty. The if expression uses the function zerop which returns true if the value it is testing is zero. When zerop tests true, the then-part of the if is evaluated. The then-part is a list starting with the function error, which is a function that is similar to the message function (see message), in that it prints a one-line message in the echo area. However, in addition to printing a message, error also stops evaluation of the function within which it is embedded. This means that the rest of the function will not be evaluated if the length of the kill ring is zero.