Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Symbol vs. String ???

8 views
Skip to first unread message

Dave Seaman

unread,
Aug 21, 1995, 3:00:00 AM8/21/95
to
In article <41aeo3$7...@pretzel.cs.huji.ac.il>,
Alexander Serebrenik <ali...@pita.cs.huji.ac.il> wrote:
>The problem is as follows - i've the variable representing string,
>f.e. (defvar x "xxx")
>Now i want to translate x to something representing `|"xxx"| .

Do you really mean you want to produce a symbol whose print name is
|"xxx"|, or are you only concerned with printing the string, complete
with quotes, but without producing an interned symbol?

>How can i do it ? (i'm working with currently existing
> module which combines structures and afterwards prints them with
>help of PRINC and the only way i found to print the string storing
>it as a STRING with the help of princ is to write
> (princ `|"xxx"|)
>The problem is that the string may be variable ...

You should probably begin by exploring the difference between prin1 and
princ, since I suspect that will solve your problem. The difference is
that princ prints a string without any surrounding quotes, while prin1
includes the quotes. In particular, (prin1 x) in your example will
produce the same output as (princ '|"xxx"|).

If that is not what you are looking for, perhaps you should try
something along the lines of the following:

>(defvar y (format nil "|~s|" x))
Y

>y
"|\"xxx\"|"

>(read-from-string y)
|"xxx"|
7

>

The value of y is a string, but the value you get from (read-from-string y)
is actually a symbol whose print name is as you indicated.

Dave Seaman

Alexander Serebrenik

unread,
Aug 21, 1995, 3:00:00 AM8/21/95
to
Hi to everybody !

I've a small problem - may be some of you already met it and know how
it may be solved ?


The problem is as follows - i've the variable representing string,
f.e. (defvar x "xxx")
Now i want to translate x to something representing `|"xxx"| .

How can i do it ? (i'm working with currently existing
module which combines structures and afterwards prints them with
help of PRINC and the only way i found to print the string storing
it as a STRING with the help of princ is to write
(princ `|"xxx"|)
The problem is that the string may be variable ...

Thanks, sincerely ,
Alexander

Erik Naggum

unread,
Aug 21, 1995, 3:00:00 AM8/21/95
to
[Alexander Serebrenik]

| [incredibly painful "solution" deleted to protect the children]

use `print' instead of `princ'.

#<Erik 3018021449>
--
trigraph ??!??! die

0 new messages