From: Jaap Weel
Subject: Question on converting string to symbol
Date: 
Message-ID: <3951ffbd.5075351@news.worldonline.nl>
Just a little question. If it's a stupid one, please point to the
appropriate chapter in CLtL2.

I can convert symbols to strings:
(string 'abcd) => "abcd"
I'd like to do the reverse now.
(string-to-symbol "abcd") => ABCD

If you want to know what project i need this for, just look in
alt.fan.hofstadter. It's a very tiny group, so the only message
containing "LISP" in its header is easily found.

From: Jason Trenouth
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <jp04lsomlldke4glt0i8tncq9qncqaqmd8@4ax.com>
On Thu, 22 Jun 2000 12:02:26 GMT, ······@worldonline.nl (Jaap Weel) wrote:

> Just a little question. If it's a stupid one, please point to the
> appropriate chapter in CLtL2.

Start using the actual ANSI Common Lisp standard or a text derived from it like
the HyperSpec (http://www.xanalys.com/software_tools/reference/HyperSpec/)
instead of the old CLtL2 snapshot.

> I can convert symbols to strings:
> (string 'abcd) => "abcd"
> I'd like to do the reverse now.
> (string-to-symbol "abcd") => ABCD

Lookup up INTERN and FIND-SYMBOL in the standard.

__Jason
From: Alexander Clark
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <3h14lskka927a38hechgqslur05b0g31kb@4ax.com>
On Thu, 22 Jun 2000 12:02:26 GMT, ······@worldonline.nl (Jaap Weel)
wrote:

>Just a little question. If it's a stupid one, please point to the
>appropriate chapter in CLtL2.
>
>I can convert symbols to strings:
>(string 'abcd) => "abcd"
>I'd like to do the reverse now.
>(string-to-symbol "abcd") => ABCD
>
>If you want to know what project i need this for, just look in
>alt.fan.hofstadter. It's a very tiny group, so the only message
>containing "LISP" in its header is easily found.

Chapter 11, section 7 (intern "abcd") or maybe find-symbol
From: Steven M. Haflich
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <3952A8F3.11C75C76@pacbell.net>
Alexander Clark wrote:
 
> Chapter 11, section 7 (intern "abcd") or maybe find-symbol

You should consider make-symbol as well, depending on whether
you want the symbol interned.  All these silly Lisp gurus
apparently miss something in their internalization of CL
language abstractions: a symbol is a first-class object
separate from its internment in packages. (:-)
From: Erik Naggum
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <3170710113433739@naggum.no>
* "Steven M. Haflich" <·······@pacbell.net>
| You should consider make-symbol as well, depending on whether you
| want the symbol interned.  All these silly Lisp gurus apparently
| miss something in their internalization of CL language abstractions:
| a symbol is a first-class object separate from its internment in
| packages. (:-)

  Nah, that's the difference between unintern and unimport.

#:Erik
-- 
  If this is not what you expected, please alter your expectations.
From: Alexander Clark
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <8va6ls49s1ph0in8s0a9palkcjbkd9ufev@4ax.com>
On Thu, 22 Jun 2000 17:01:55 -0700, "Steven M. Haflich"
<·······@pacbell.net> wrote:

>
>
>Alexander Clark wrote:
> 
>> Chapter 11, section 7 (intern "abcd") or maybe find-symbol
>
>You should consider make-symbol as well, depending on whether
>you want the symbol interned.  All these silly Lisp gurus
>apparently miss something in their internalization of CL
>language abstractions: a symbol is a first-class object
>separate from its internment in packages. (:-)

What are some uses for uninterned symbols?  Hygienic macros?
I'm not very clear on when to use symbols at all.  I tend to avoid
them.
From: Erik Naggum
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <3170743858222008@naggum.no>
* Alexander Clark <···@aclark.spam.demon.co.uk>
| What are some uses for uninterned symbols?

  They're great when you need to refer to symbols captured by some
  other means than their symbol name, or used by some other parts of
  the system than the Lisp reader.  One nice thing about uninterned
  symbols is that two of them can have the same name without colliding.

| Hygienic macros?

  Macros.  (Hygiene is something the Scheme people need.)

| I'm not very clear on when to use symbols at all.  I tend to avoid
| them.

  Wow.  How do you write code without symbols?

#:Erik
-- 
  If this is not what you expected, please alter your expectations.
From: Alexander Clark
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <5lh6ls4t91bmgltv6h5rdbg6drke91qmf5@4ax.com>
On 23 Jun 2000 10:10:58 +0000, Erik Naggum <····@naggum.no> wrote:

>* Alexander Clark <···@aclark.spam.demon.co.uk>

>| I'm not very clear on when to use symbols at all.  I tend to avoid
>| them.
>
>  Wow.  How do you write code without symbols?
>
>#:Erik

With difficulty.

 I meant, when are symbols the right data structure to use? What are
the considerations that bear on this decision?  What do you gain by
using symbols rather than a user defined data structure?
From: Erik Naggum
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <3170667252754195@naggum.no>
* Jaap Weel
| Just a little question. If it's a stupid one, please point to the
| appropriate chapter in CLtL2.

  As others have pointed out, too: CLtL2 is superseded by the actual
  standard, which I prefer to call CLtS, but that's informal at best.

| I can convert symbols to strings:
| (string 'abcd) => "abcd"
| I'd like to do the reverse now.
| (string-to-symbol "abcd") => ABCD

  For hysterical raisons, symbol names in Common Lisp are in uppercase
  and the Lisp reader is case insensitive, which throws most people's
  expectations off.  The symbol named "abcd" prints as |abcd|, and the
  symbol named "ABCD" prints as abcd if you have set *print-case* to
  :downcase, which many do.  In any case, reading abcd yields the
  symbol named "ABCD".  (eq 'abcd (intern "ABCD")) holds for all abcd.

#:Erik
-- 
  If this is not what you expected, please alter your expectations.
From: Kent M Pitman
Subject: Re: Question on converting string to symbol
Date: 
Message-ID: <sfw66r1l87g.fsf@world.std.com>
Erik Naggum <····@naggum.no> writes:

>   In any case, reading abcd yields the
>   symbol named "ABCD".  (eq 'abcd (intern "ABCD")) holds for all abcd.

Especially when *package* is held constant between the time the 
above expression is seen by READ and the time execution of the
expression occurs. ;-)

My only point being, since no one else seems to have mentioned it,
that INTERN and FIND-SYMBOL are, in some sense, not inverses but
are one-to-many functions, the which of the many being determined
by dynamic state (specifically, the binding of *package*).  There
is no single symbol which is the result of (intern "ABCD").

This also means people must be careful about 
  (eq x (intern (string x)))
since if x has a package other than the prevailing package, then
  (eq 'foo::x (intern (string 'foo::x)))
will yield false.

As a rule, the right answer to "how do I undo (string sym)?" is not
"(intern sym)" but to ask the question "what are you really trying to do?"
The question is almost surely an indication that the person asking the
question is doing something wrong at a higher level.  This is not to
say there aren't good uses for FIND-SYMBOL and INTERN, but undoing a
call to STRING is almost never, in my experience, one of them.