From: Pankaj S. Mody
Subject: please help me!
Date: 
Message-ID: <IfaHg7200Uh_Q4eGls@andrew.cmu.edu>
I want to be able to do something like the follwing:

> (setf (make-symbol "foo") 29.7)

> foo
[should return 29.7 as the value of the symbol foo]

When I try this, the debugger says foo is unbound. 
In other words, I am trying to create a symbol whose name is given in a
string, and then be able to use it - i.e. bound the symbol to some
value. 
I need to know how to do this because in my code, I would like to be
able to create a symbol whose name is user-specified at run-time. I know
this is possible, I just can't figure out how to do this. I tried all
the symbol functions listed in GUY STEELE's COMMON LISP reference, but
to no avail. 

Any help would be appreciated. Thanx in advance!

Pankaj

From: Scott McKay
Subject: please help me!
Date: 
Message-ID: <19930307155723.6.SWM@SUMMER.SCRC.Symbolics.COM>
    Date: Sat, 6 Mar 1993 19:00 EST
    From: "Pankaj S. Mody" <·····@andrew.cmu.edu>

    I want to be able to do something like the follwing:

    > (setf (make-symbol "foo") 29.7)

    > foo
    [should return 29.7 as the value of the symbol foo]

    When I try this, the debugger says foo is unbound. 
    In other words, I am trying to create a symbol whose name is given in a
    string, and then be able to use it - i.e. bound the symbol to some
    value. 
    I need to know how to do this because in my code, I would like to be
    able to create a symbol whose name is user-specified at run-time. I know
    this is possible, I just can't figure out how to do this. I tried all
    the symbol functions listed in GUY STEELE's COMMON LISP reference, but
    to no avail. 

    Any help would be appreciated. Thanx in advance!

    Pankaj

MAKE-SYMBOL creates an uninterned symbol.  Use INTERN instead.
From: david kuznick
Subject: Re: please help me!
Date: 
Message-ID: <1993Mar8.093406.5758@titan.ksc.nasa.gov>
In article <····················@SUMMER.SCRC.Symbolics.COM>, ···@stony-brook.scrc.symbolics.com (Scott McKay) writes:
Relay-Version: VMS News - V6.0-3 14/03/90 VAX/VMS V5.5; site titan.ksc.nasa.gov
Path: titan.ksc.nasa.gov!ames!olivea!mintaka.lcs.mit.edu!gateway
Newsgroups: comp.lang.lisp
Subject: please help me!
Message-ID: <····················@SUMMER.SCRC.Symbolics.COM>
From: ···@stony-brook.scrc.symbolics.com (Scott McKay)
Date: Sun, 7 Mar 93 10:56:17 EST
Sender: ····@mintaka.lcs.mit.edu
References: <··················@andrew.cmu.edu>
Organization: LCS news/mail gateway
X-Unparseable-Date: Sun
Lines: 26


    Date: Sat, 6 Mar 1993 19:00 EST
    From: "Pankaj S. Mody" <·····@andrew.cmu.edu>

    I want to be able to do something like the follwing:

    > (setf (make-symbol "foo") 29.7)

    > foo
    [should return 29.7 as the value of the symbol foo]

    When I try this, the debugger says foo is unbound. 
    In other words, I am trying to create a symbol whose name is given in a
    string, and then be able to use it - i.e. bound the symbol to some
    value. 
    I need to know how to do this because in my code, I would like to be
    able to create a symbol whose name is user-specified at run-time. I know
    this is possible, I just can't figure out how to do this. I tried all
    the symbol functions listed in GUY STEELE's COMMON LISP reference, but
    to no avail. 

    Any help would be appreciated. Thanx in advance!

    Pankaj

> MAKE-SYMBOL creates an uninterned symbol.  Use INTERN instead.

And also remember to use upper case for the argument for intern, or else you
will have to refer to the symbol created by (intern "foo") as |foo| (telling
Lisp not to convert what you type in a symbol name to upper-case).

--
**
David Kuznick
·······@meglos.mdcorp.ksc.nasa.gov
MUTLEY! Do something!  - D.D.
From: Barry Margolin
Subject: Re: please help me!
Date: 
Message-ID: <1ng093INNcjr@early-bird.think.com>
In article <····················@SUMMER.SCRC.Symbolics.COM> ···@stony-brook.scrc.symbolics.com (Scott McKay) writes:
>    Date: Sat, 6 Mar 1993 19:00 EST
>    From: "Pankaj S. Mody" <·····@andrew.cmu.edu>
>
>    > (setf (make-symbol "foo") 29.7)
>
>    > foo

>MAKE-SYMBOL creates an uninterned symbol.  Use INTERN instead.

Also, you have to setf the SYMBOL-VALUE:

(setf (symbol-value (intern "FOO")) 29.7)
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar
From: Mike Haynie
Subject: Re: please help me!
Date: 
Message-ID: <MBH.93Mar8124012@wisdom.wisdom.attmail.com>
In article <··················@andrew.cmu.edu> "Pankaj S. Mody" <·····@andrew.cmu.edu> writes:

   I want to be able to do something like the follwing:

   > (setf (make-symbol "foo") 29.7)

I don't think that SETF is defined for a place form like (make-symbol "foo")...

   > foo
   [should return 29.7 as the value of the symbol foo]

You should do something like;

(set (intern "foo") 29.7)

then |foo| => 29.7 because

1. (intern "foo") /= (intern "FOO") !!!

The case of the string is preserved for both MAKE-SYMBOL and INTERN,
so that (intern "foo") => |foo|. The LISP reader will *usually*
uppercase symbols. (Some LISPs do this differently...), and |foo| and
FOO are different symbols

2. set /= setq /= setf

SETF expects a place form, which MAKE-SYMBOL is not (maybe be this was
a typo?). SETQ expects a symbol, and will not evaluate to get one (q
== quote). Thus, since you want to SET the value of a symbol that you
are constructing, SET seems to be the right form to use.

Hope this helps.
--

                                ____/|
Michael Haynie                  \ o.O|   ACK!
···@wisdom.attmail.com           =(_)=  THPHTH!
                                   U
From: Richard Levitte
Subject: Re: please help me!
Date: 
Message-ID: <LEVITTE.93Mar8232933@elin.e.kth.se>
>>>>> On Sat,  6 Mar 1993 19:00:07 -0500 , "Pankaj S. Mody" <·····@andrew.cmu.edu> said:

PSM> I want to be able to do something like the follwing:

> (setf (make-symbol "foo") 29.7)

> foo
PSM> [should return 29.7 as the value of the symbol foo]

PSM> When I try this, the debugger says foo is unbound. 

Of course, because make-symbol creates an uninterned symbol. Try this
instead:

> (setq (intern "foo") 29.7)
29.7
> foo
29.7

--
!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! Richard Levitte, VMS GNU Emacs hacker   ! tel: int+46-8-18 30 99            !
! Sulv"agen 57, II                        ! fax: none for the moment          !
! S-126 40 H"agersten                     ! Internet: ·······@e.kth.se        !
! SWEDEN                                  !                                   !
!-----------------------------------------------------------------------------!
From: Carl L. Gay
Subject: Re: please help me!
Date: 
Message-ID: <CGAY.93Mar8170835@majestix.cs.uoregon.edu>
   Newsgroups: comp.lang.lisp
   From: ·······@e.kth.se (Richard Levitte)
   Date: 8 Mar 93 2:29pm PST

   PSM> I want to be able to do something like the follwing:

   > (setf (make-symbol "foo") 29.7)
   > foo
   PSM> [should return 29.7 as the value of the symbol foo]

   PSM> When I try this, the debugger says foo is unbound. 

   Of course, because make-symbol creates an uninterned symbol. Try this
   instead:

   > (setq (intern "foo") 29.7)
   29.7
   > foo
   29.7

Ahem.  Did you actually type this into a Lisp REPL?  Which Lisp?  SETQ
doesn't evaluate its 1st arg so this won't work.  SETF won't work
either, since there is no SETF method for INTERN or MAKE-SYMBOL.
(What would they do?)

Why not just use SET?

? (set (intern (string-upcase "foo")) 29.7)
29.7
? fraz
29.7

And the obligatory question "What are you *really* trying to do?"

I'm surprised there have been several wrong/incomplete answers to this
question, especially coming from some very knowledgable Lispers.
(Barmar got it right, como de costumbre.)

-Carl