In article <770dr4$1h...@nnrp1.dejanews.com>,
<robert_m_mi
...@yahoo.com> wrote:
>Is this possible? Say I want my code to take the name `human' from the user
>and create a new class named human. I could do
>But there probably is a way to get the first arg of defclass to evaluate to a
>form or symbol without using eval, right?
Since DEFCLASS is a macro.... no. DEFCLASS doesn't evaluate the
first argument. So you will need to "eval" the whole statement.
By the way.... backquote is useful in this context.
USER(13): (eval `(defclass ,(read) () ((name :accessor name))) )
human
#<STANDARD-CLASS HUMAN>
USER(14): (describe 'human )
HUMAN is a SYMBOL.
It is unbound.
It is INTERNAL in the COMMON-LISP-USER package.
It names a class #<STANDARD-CLASS HUMAN>
USER(15):
P.S. If you lisp implementation has a directway of creating
classess then you wouldn't need eval. Something along he
lines of
(progn
.... pre creation magic ...
(make-instance 'standard-class ... some magic ... )
.... post creation magic ... )
There may be a MOP way of doing creating a new class... but I
can't remember at the moment. As much as I like to discourage
use of eval, it works in this context. ;-)
[ It isn't necessary, but it is the quick, portable solution. ]
--
Lyman S. Taylor "I'm a Doctor! Not a commando."
(ly...@cc.gatech.edu) The enhanced EMH Doctor in a ST:Voyager epidsode.