Article View: comp.lang.lisp.x
Article #137Re: Accessing READTABLE in Xlisp 2.1
From: Tim Mikkelsen
Date: Fri, 21 Sep 1990 02:57
Date: Fri, 21 Sep 1990 02:57
68 lines
3236 bytes
3236 bytes
set-macro-character ________________________________________________________________________ type: defined function (closure) location: extension source file: init.lsp Common LISP compatible: related supported on: all machines SYNTAX (set-macro-character <char-num> <function> [ <termflag> ] ) <char-num> - an integer expression <function> - a function definition <termflag> - an expression - NIL or non-NIL DESCRIPTION The SET-MACRO-CHARACTER function installs the code that will be executed when the specified character <char-num> is encountered by the XLISP reader. The <function> is placed in 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 NIL, :CONSTITUENT, :SESCAPE, :MESCAPE, :WHITE-SPACE, a :TMACRO dotted pair or a :NMACRO dotted pair. The SET-MACRO-CHARACTER function only allows you to put in a terminating read-macro function (:TMACRO) or a non-terminating read-macro-function (:NMACRO). If the <termflag> is present and non-NIL, then the <function> will be put in *READTABLE* as a :TMACRO entry. If <termflag> is not present or NIL, then <function> will be put in *READTABLE* as a :NMACRO entry. The <function> can be a built-in read-macro function or a user defined defun symbol or a 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 SET-MACRO-CHARACTER always returns T. EXAMPLES (print "hi") % comment ; prints "hi" and gives ; error: unbound variable - % ; because percent is viewed ; as a variable ; (setq semi (get-macro-character #\;)) ; get semi-colon code ; (SET-MACRO-CHARACTER #\% semi T) ; set % to work as a comment ; (print "hi") % comment ; prints "hi" and no error ; because % is now a comment ; character in *READTABLE* NOTE: In the normal XLISP system the following characters have code associated with them in the *READTABLE*: " # ' ( ) , ; ` NOTE: The functions GET-MACRO-CHARACTER and SET-MACRO-CHARACTER are created in the INIT.LSP file. If they do not exist in your XLISP system, you might be having a problem with INIT.LSP. Before you start XLISP, look in the directory you are currently in, and check to see if there is an INIT.LSP. COMMON LISP COMPATABILITY: The SET-MACRO-CHARACTER function is somewhat related to the Common LISP SET-DISPATCH-MACRO-CHARACTER function.
Technical Details
Message-ID:
<1170011@hpfcbig.SDE.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfcbig!timReferences:
<1990Sep20.003513.14808@cs.utk.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpfcso!hpfcbig!tim From: tim@hpfcbig.SDE.HP.COM (Tim Mikkelsen) Newsgroups: comp.lang.lisp.x Subject: Re: Accessing READTABLE in Xlisp 2.1 Message-ID: <1170011@hpfcbig.SDE.HP.COM> Date: 21 Sep 90 02:57:54 GMT References: <1990Sep20.003513.14808@cs.utk.edu> Organization: HP SESD, Fort Collins, CO Lines: 68