The 'get-macro-character' function returns the code that will be
executed when the specified character 'char' is encountered by the XLISP
reader. The returned value is taken from the
*readtable* system variable which contains
the reader table array. The table is 128 entries [0..127] for each of the
7-bit ASCII characters that XLISP can read. Each entry in the table must be
one of
The 'get-macro-character' function will return a
NIL value if the table entry is
The function returned may 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.
(defun get-macro-character (ch) (if (consp (aref *readtable* (char-int ch))) (cdr (aref *readtable* (char-int ch))) nil))
Note: This function is not included in the standard Nyquist distribution. If you want to use it, copy the code above to your 'init.lsp' file.
(get-macro-character #\() ; returns #<Subr-: #...> (get-macro-character #\#) ; returns #<Subr-: #...> (get-macro-character #\Space) ; returns NIL
Note: In the normal XLISP system the following characters have code associated with them in the *readtable*:
" # ' ( ) , ; `
[double-quote, hash, quote, opening parenthesis, closing parenthesis, comma, semicolon, backquote]
Common Lisp: The 'get-macro-character' function is somewhat related to the Common Lisp 'get-dispatch-macro-character' function.
See also the XLISP Plus set-macro-character function.