Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Question on converting string to symbol
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  10 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jaap Weel  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: ajw...@worldonline.nl (Jaap Weel)
Date: 2000/06/22
Subject: Question on converting string to symbol
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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Trenouth  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Jason Trenouth <ja...@harlequin.com>
Date: 2000/06/22
Subject: Re: Question on converting string to symbol

On Thu, 22 Jun 2000 12:02:26 GMT, ajw...@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


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Clark  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Alexander Clark <a...@aclark.spam.demon.co.uk>
Date: 2000/06/22
Subject: Re: Question on converting string to symbol
On Thu, 22 Jun 2000 12:02:26 GMT, ajw...@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

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/22
Subject: Re: Question on converting string to symbol
* 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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kent M Pitman  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Kent M Pitman <pit...@world.std.com>
Date: 2000/06/22
Subject: Re: Question on converting string to symbol

Erik Naggum <e...@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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Steven M. Haflich  
View profile  
 More options Jun 22 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: "Steven M. Haflich" <hafl...@pacbell.net>
Date: 2000/06/22
Subject: Re: Question on converting string to symbol

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. (:-)

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jun 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/23
Subject: Re: Question on converting string to symbol
* "Steven M. Haflich" <hafl...@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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Clark  
View profile  
 More options Jun 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Alexander Clark <a...@aclark.spam.demon.co.uk>
Date: 2000/06/23
Subject: Re: Question on converting string to symbol
On Thu, 22 Jun 2000 17:01:55 -0700, "Steven M. Haflich"

<hafl...@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.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jun 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.no>
Date: 2000/06/23
Subject: Re: Question on converting string to symbol
* Alexander Clark <a...@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.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alexander Clark  
View profile  
 More options Jun 23 2000, 3:00 am
Newsgroups: comp.lang.lisp
From: Alexander Clark <a...@aclark.spam.demon.co.uk>
Date: 2000/06/23
Subject: Re: Question on converting string to symbol
On 23 Jun 2000 10:10:58 +0000, Erik Naggum <e...@naggum.no> wrote:

>* Alexander Clark <a...@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?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »