how can I implement this in macro?

From: lisplover (lisplover_at_hotmail.com)
Date: 03/29/05


Date: 28 Mar 2005 17:22:54 -0800

I am reading PG's on lisp and find this

(defvar *!equivs* (make-hash-table))
(defun ! (fn)
    (or (gethash fn *!equivs*) fn))
(defun def! (fn fn!)
    (setf (gethash fn *!equivs*) fn!))

to return a destructive equivalent. He comments that "Since the
relation between a function and its destructive counterpart will
usually be known before runtime, it would be most efficient to define !
as a macro, or even provide a read macro for it."
I try to implement that in macro. but find that when I define
(defmacro !(fn)
  `(gethash (symbol-function ',fn) *!equivs*))
It is fine to call
CL-USER>(funcall (! reverse) '(1 2))
->(2 1)

But when I call it through a function

CL-USER> (defun test2(fn)
           (funcall (! fn) '(1 2)))
TEST2
CL-USER> (test2 'reverse)
Error occurs.
SYMBOL-FUNCTION: undefined function FN
   [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]

Would anyone like to point out what is the proper way to do it in
macro? Thanks.



Relevant Pages

  • Re: Reversing a list - Back again!
    ... OK - Plan B. Again assuming each line is a paragraph, the following macro ... will reverse the list on a place by place basis. ... London Town ...
    (microsoft.public.word.newusers)
  • Re: Aperture - love it.
    ... >>> Tell me what aperture setting is optimal for a macro to maximize focus ... > maximum depth of field you stop the lens all the way down. ... This will approx triple your magnification. ... Go here and search for 'reverse' for a better explanation: ...
    (comp.sys.mac.advocacy)
  • Re: autonumbering
    ... Hmm, if you want to number text in a single sequence, you can use the macro ... Note that the macro keeps track of the sequence by storing the current value ... reverse the order starting from 1 at the bottom of the sheet and adding ... create a reverse numbering sequence. ...
    (microsoft.public.word.docmanagement)
  • Re: Macro to number blank cells
    ... Anne Troy (better known as Dreamboat) ... (Reverse it!) ... > I have a macro that inserts 6 rows below each name, ...
    (microsoft.public.excel)
  • Re: Button Problem
    ... Are you saying you have two macros -one to sub total the other to reverse it, if yes post your code as I suspect that may be the problem. ... When I push the button it kicks off the macro and subtotals the sheet. ...
    (microsoft.public.excel.programming)