Hi,
I'm looking for some help,
I'm trying to access a slot of a CLOS object that has a certain name,
coming from a string "name"
To make things clearer, why does cg-user(55) in the example work while
cg-user(56) doesn't?
(defclass arena ()(longname map))
#<STANDARD-CLASS ARENA>
CG-USER(54): (defvar sth (make-instance 'arena))
STH
CG-USER(55): (slot-exists-p sth 'longname)
T
CG-USER(56): (slot-exists-p sth (find-symbol "longname" (package-name
*package*)))
NIL
thanks,
Greetings,
Johan
From: Edi Weitz
Subject: Re: Question about symbols, slot-exists-p and find-symbol
Date:
Message-ID: <ud5kgnv41.fsf@agharta.de>
On Fri, 02 Dec 2005 02:21:37 +0100, Jovdbroe <········@vub.ac.be> wrote:
> I'm trying to access a slot of a CLOS object that has a certain
> name, coming from a string "name" To make things clearer, why does
> cg-user(55) in the example work while cg-user(56) doesn't?
>
> (defclass arena ()(longname map))
> #<STANDARD-CLASS ARENA>
> CG-USER(54): (defvar sth (make-instance 'arena))
> STH
> CG-USER(55): (slot-exists-p sth 'longname)
> T
> CG-USER(56): (slot-exists-p sth (find-symbol "longname" (package-name
> *package*)))
> NIL
Assuming that you're /not/ using AllegroCL's "modern" mode you should
try
(find-symbol "LONGNAME" (package-name *package*))
instead. Try
(symbol-name 'longname)
And, by the way, why don't you use it like this?
(find-symbol "LONGNAME" *package*)
Cheers,
Edi.
--
Lisp is not dead, it just smells funny.
Real email: (replace (subseq ·········@agharta.de" 5) "edi")
Thanks!
Worked like a charm.
Edi Weitz wrote:
> On Fri, 02 Dec 2005 02:21:37 +0100, Jovdbroe <········@vub.ac.be> wrote:
>
>
>>I'm trying to access a slot of a CLOS object that has a certain
>>name, coming from a string "name" To make things clearer, why does
>>cg-user(55) in the example work while cg-user(56) doesn't?
>>
>>(defclass arena ()(longname map))
>>#<STANDARD-CLASS ARENA>
>>CG-USER(54): (defvar sth (make-instance 'arena))
>>STH
>>CG-USER(55): (slot-exists-p sth 'longname)
>>T
>>CG-USER(56): (slot-exists-p sth (find-symbol "longname" (package-name
>>*package*)))
>>NIL
>
>
> Assuming that you're /not/ using AllegroCL's "modern" mode you should
> try
>
> (find-symbol "LONGNAME" (package-name *package*))
>
> instead. Try
>
> (symbol-name 'longname)
>
> And, by the way, why don't you use it like this?
>
> (find-symbol "LONGNAME" *package*)
>
> Cheers,
> Edi.
>
From: Thomas A. Russ
Subject: Re: Question about symbols, slot-exists-p and find-symbol
Date:
Message-ID: <ymizmnfo3a1.fsf@sevak.isi.edu>
Jovdbroe <········@vub.ac.be> writes:
> To make things clearer, why does cg-user(55) in the example work while
> cg-user(56) doesn't?
>
> (defclass arena ()(longname map))
> #<STANDARD-CLASS ARENA>
> CG-USER(54): (defvar sth (make-instance 'arena))
> STH
> CG-USER(55): (slot-exists-p sth 'longname)
> T
> CG-USER(56): (slot-exists-p sth (find-symbol "longname" (package-name
> *package*)))
> NIL
Well, what does (find-symbol "longname" (package-name *package*))
return?
Are you surprised?
If so, look at (symbol-name 'longname)
and use the result of that in FIND-SYMBOL.
--
Thomas A. Russ, USC/Information Sciences Institute