From: Haig F. Krikorian
Subject: DEFSUBST help
Date: 
Message-ID: <691s88$8k1@nntp02.primenet.com>
I have a lot of TI expoorer code I am converting to CLOS.  
I cannot find any docusmentation on the DEFSUBST construct. 

I woudl appreciate any help before I go plow through a lot of ugly
looking DEFMACRO code as I conver t my stuff to CLOS..


- Haig 
From: Kent M Pitman
Subject: Re: DEFSUBST help
Date: 
Message-ID: <sfwd8i3ue6d.fsf@world.std.com>
ยทยทยทยท@primenet.com (Haig F. Krikorian) writes:

> I have a lot of TI expoorer code I am converting to CLOS.
> I cannot find any docusmentation on the DEFSUBST construct. 
> I woudl appreciate any help before I go plow through a lot of ugly
> looking DEFMACRO code as I conver t my stuff to CLOS..

It's mostly an inline function, except that by special exception
the compiler is willing to inspect the definition and construct an
appropriate SETF method if needed.  If you don't need the SETF part,
you should approximately be able to win with the following:

(defmacro defsubst (name bvl &body forms)
  `(progn
     (declaim (inline ,name))
     (defun ,name ,bvl ,@forms)))

However, CL inlinable-functions are not automatically SEFable.
If you find cases where the person is expecting the result to
be SETFable, you might try something more elaborate like the
following (which I didn't test--it's just a guess):

(defmacro defsubst (name bvl &body forms) ;SETFable
  (let ((argvar (gensym)) 
	(valvar (gensym))
        (prolog (butlast forms))
	(lastform (car (last forms))))
    `(progn 
       (declaim (inline ,name))
       (defun ,name ,bvl ,@forms)
       (defsetf ,name (&rest ,argvar) (,valvar)
         `(destructuring-bind ,',bvl (list ,@,argvar)
            ,@',prolog ;declarations ok
            (setf ,',lastform ,,valvar)))
       ',name)))