|
Re: New, from-scratch implementation of backquote.: msg#00076lisp.clisp.general
On 11 Apr 2003, Todd Sabin wrote: > Perhaps it's obvious, but the last message was unfinished; I never > noticed how close C-c C-c is to C-x C-x before :\ > > Anyway, the code I sent doesn't do what I thought it did, so just ignore > me for now... :) Yep. It returns the list (defclass ...) which still needs to be EVAL-ed. You can't fix this, because you can't get around the fact that defclass is a compile-time construct. To define a new class at run-time, you need to construct a new instance of the defclass syntax, and to activate it, you must either EVAL it, or put it in a lambda body and COMPILE it, and then funcall the resulting object. The other alternative would be to use the underlying ENSURE-CLASS function, but that is not portable, (except where the MOP is implemented)? So we can repair your function by moving the backquote out to the whole lambda, and then by using the COMPILE function---which is probably kind of a waste of cycles just to run defclass once. ;) ;; original recipe (defun defclass* (name supers slots &rest options) (funcall (lambda () `(defclass ,name ,supers ,slots ,@options)))) ;; extra crispy (defun defclass* (name supers slots &rest options) (funcall (compile nil `(lambda () (defclass ,name ,supers ,slots ,@options))))) ;; calorie reduced (defun defclass* (name supers slots &rest options) (eval `(defclass ,name ,supers ,slots ,@options))) ------------------------------------------------------- This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger for complex code. Debugging C/C++ programs can leave you feeling lost and disoriented. TotalView can help you find your way. Available on major UNIX and Linux platforms. Try it free. www.etnus.com |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: New, from-scratch implementation of backquote.: 00076, Todd Sabin |
|---|---|
| Next by Date: | Re: New, from-scratch implementation of backquote.: 00076, Todd Sabin |
| Previous by Thread: | Re: Re: New, from-scratch implementation of backquote.i: 00076, Todd Sabin |
| Next by Thread: | Re: New, from-scratch implementation of backquote.: 00076, Todd Sabin |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |