Jump to content

Page:AITR-474.djvu/134

From Wikisource
This page needs to be proofread.
124

WARN is a macro used to print a notice concerning an incorrect program being compiled. It generates a call to PRINT-WARNING, which maintains a count and a list of the error messages, and prints the message, along with any associated useful quantities.

(WARN |FOO is greater than BAR| FOO BAR)

would print (assuming the values of FOO and BAR were 43 and 15)

;Warning: FOO is greater than BAR
; 43
; 15

WARN is used only to report errors in the program being compiled. The MacLISP ERROR function is used to signal internal inconsistencies in the compiler.

ASK is a macro which prints a message and then waits for a reply. Typically NIL means "no", and anything else means ”yes".

SX and CSX are debugging aids which print intermediate data structures internal to the compiler in a readable form. They make use of SPRINTER (part of the MacLISP GRIND pretty-printing package) and of SEXPRFY and CSEXPRFY, which are defined below.

The EQCASE macro provides a simple dispatching control structure. The first form evaluates to an item, and the clause whose keyword matches the item is executed. If no clause matches, an error occurs. For example:

(EQCASE TRAFFIC-LIGHT
        (RED (PRINT 'STOP))
        (GREEN (PRINT 'GO))
        (YELLOW (PRINT 'ACCELERATE) (CRASH)))

expands into the code:

(COND ((EQ TRAFFIC-LIGHT RED) (PRINT 'STOP))
      ((EQ TRAFFIC-LIGHT 'GREEN) (PRINT 'GO))
      ((EQ TRAFFIC-LIGHT 'YELLOW) (PRINT 'ACCELERATE) (CRASH))
      (T (ERROR '|Losing EQCASE| TRAFFIC-LIGHT 'FAIL-ACT)))