A table used to associate function names with macro names
Example Form: (table macro-aliases-table 'append 'binary-append)
This example associates the function symbol binary-append with the macro name append. As a result, the name append may be used as a runic designator (see theories) by the various theory functions. Thus, for example, it will be legal to write
(in-theory (disable append))
as an abbreviation for
(in-theory (disable binary-append)). General Form: (table macro-aliases-table 'macro-name 'function-name)
or more generally
(table macro-aliases-table macro-name-form function-name-form)
where
After admitting the table event displayed above, we may say that
See table for a general discussion of tables and the
As hinted above, this table is used by theory functions; see theories. For example, in order that
Note that the value
;;;;;;;;;; ;;; Example 1: No errors, with function defined before setting the table. ;;;;;;;;;; (defun fn (x) x) (defmacro mac (x) (list 'fn x)) (table macro-aliases-table 'mac 'fn) ; or (add-macro-alias mac fn) (in-theory (disable mac)) ;;;;;;;;;; ;;; Example 2: No errors, with function defined after setting the table. ;;;;;;;;;; (defmacro mac (x) (list 'fn x)) ; Legal, even though fn is not yet defined: (table macro-aliases-table 'mac 'fn) ; or (add-macro-alias mac fn) (defun fn (x) x) (in-theory (disable mac)) ;;;;;;;;;; ;;; Example 3: ERROR. ;;;;;;;;;; (defun fn (x) x) (defmacro mac1 (x) (fn x)) (defmacro mac2 (x) (list 'mac1 x)) ; BAD, since the table event above anticipates fn to be defined as ; a function, not a macro (but, no error yet) -- but not (yet) an error: (table macro-aliases-table 'mac2 'mac1) ; or (add-macro-alias mac2 mac1) ; ERROR, since mac2 does not designate rules, because it aliases a macro: (in-theory (disable mac2)) ; OK, but too late to help with that in-theory event; see below: (table macro-aliases-table 'mac1 'fn) ; or (add-macro-alias mac1 fn) ; ERROR, since mac2 is still associated with mac1, not with fn: (in-theory (disable mac2)) ;;;;;;;;;; ;;; Example 4: Fixed version of Example 3. ;;;;;;;;;; (defun fn (x) x) (defmacro mac1 (x) (fn x)) (defmacro mac2 (x) (list 'mac1 x)) (add-macro-alias mac1 fn); or (table macro-aliases-table 'mac1 'fn) ; The following is equivalent to (add-macro-alias mac2 fn), since ; mac1 is a macro-alias for fn by virtue of the preceding event. (add-macro-alias mac2 mac1) ; Success: (in-theory (disable mac2))