XLISP :nmacro

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference

# :nmacro

Type: | - | keyword
Source: | - | xlread.c

## Syntax

(:nmacro . function)
  function - a function

## Description

':nmacro' is an entry that is used in the *readtable* system variable that contains XLISP's data structures relating to the processing of characters from the user [or files] and read-macro expansions. The existance of the ':nmacro' keyword means that the specified character is the start of a non-terminal read macro. For ':nmacro', the form of the *readtable* entry is a dotted pair like:

    (:nmacro . function)

The 'function' can be a built-in read-macro function or a user defined lambda expression. The 'function' takes two parameters, an input stream specification, and an integer that is the character value. The 'function' should return NIL if the character is 'white-space' or a value consed with NIL to return the value. The 'function' will probably read additional characters from the input stream.

## Examples

    (defun look-at (table)                ; define a function to
      (dotimes (ch 127)                   ;   look in a table
        (prog ((entry (aref table ch)))   ;   and print out any
          (if (and (consp entry)          ;   :NMACRO entries
                   (equal (car entry)
                          ':nmacro))
              (princ (int-char ch)))))
      (terpri))
    (look-at *readtable*)                 ;  prints #

Note: The system defines that the hash [#] character is a non-terminal. This is because the hash is used for a variety of 'read macro expansions' including function, an ASCII code, and hexadecimal numbers.

Caution: If you experiment with *readtable* , it is useful to save the old value in a variable, so that you can restore the system state.

See the :nmacro keyword in the XLISP 2.0 manual.

Back to Top

Nyquist / XLISP 2.0 - Contents | Tutorials | Examples | Reference