[plt-scheme] String->symbol question.

From: Robby Findler (robby at cs.uchicago.edu)
Date: Mon Mar 21 19:46:41 EST 2005

At Tue, 22 Mar 2005 01:20:55 +0100 (CET), Vladimir BODNARTCHOUK wrote:
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> Hello
> 
> Is there an easy way to force this string "[#0000ff]" to be a symbol ?
> 
> Because (string->symbol "[#0000ff]") gives |[#0000ff]| and '#\[#\##\0#\0#\0#\0#\f#\f#\] 
> ...  not really what i need.

This:

  '[#0000ff]

is not a symbol, it's a list -- the square brackets are interpreted as
parenthesis. So, if you want them to appear in a symbol, they must be
quoted, either like this:

  '\[#0000ff\]

or like this:

  '|[#0000ff]|

The symbol doesn't really have the bars or the backslashes in it's
name, it's just that it has to be printed like that, so it the brackets
aren't interpreted as lists (when it's read back in later).

Robby



Posted on the users mailing list.