From: Raphael.Maree.
Subject: [Q] slots, get, packages, macro
Date: 
Message-ID: <38DBF243.63B86F@nospams.net>
Hello,

My slots defined in the user package can be read with
(get 'age 'source)
Important note: age and source are unbound.

I would like to read these slots from
a function in the foo package. 
(get user:'age user:'source) and user:(get 'age 'source) work, 
but the first name (here: age) is not always the same,
it's read in a list of string in the foo package.

For example, in the foo package i have the list ("age") and i would 
like that myfunction access slots defined in the user package.
So, what i want is something like that:
(defun myfunction (name)
   (mymacro name source)
)
and (myfunction "age") should return the slots value.

Is it possible ?
Thanks.
--
From: Barry Margolin
Subject: Re: [Q] slots, get, packages, macro
Date: 
Message-ID: <pySC4.98$b22.2489@burlma1-snr2>
In article <···············@nospams.net>,
Raphael.Maree. <·········@nospams.net> wrote:
>Hello,
>
>My slots defined in the user package can be read with
>(get 'age 'source)
>Important note: age and source are unbound.
>
>I would like to read these slots from
>a function in the foo package. 
>(get user:'age user:'source) and user:(get 'age 'source) work, 
>but the first name (here: age) is not always the same,
>it's read in a list of string in the foo package.

The correct syntax is (get 'user:age 'user:source).  The colons are part of
the syntax for entering symbols.

>For example, in the foo package i have the list ("age") and i would 
>like that myfunction access slots defined in the user package.
>So, what i want is something like that:
>(defun myfunction (name)
>   (mymacro name source)
>)
>and (myfunction "age") should return the slots value.

(defun myfunction (name)
  (get (intern name 'user) 'source))

Note that the proper way to call this would be (myfunction "AGE"), since
symbol names are normally uppercased by the reader.

-- 
Barry Margolin, ······@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.