help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to convert a string to a symbol?


From: Richard G Riley
Subject: Re: how to convert a string to a symbol?
Date: Sun, 14 Sep 2008 12:19:22 +0200
User-agent: Emacs 22.2.1/No Gnus v0.11

"Drew Adams" <drew.adams@oracle.com> writes:

>> > (setq str "(> 2 1)")
>> > I want something like: (eval (string-to-symbol str))
>> 
>> (intern str)
>
> And if you really want the value of the symbol (per your use of `eval' above):
>
> (symbol-value (intern str))
>
> But you might want to give it a value first ;-) -
>
> (set (intern "(> 2 1)") 42)
>
> (symbol-value '\(>\ 2\ 1\)) ; The answer is 42.
>
> However, as always with questions of this type, one wonders what you are
> _really_ trying to do (not to mention why)...

It seems from the mention of eval quite clear (not being an elisp
programmer myself). He wants the result of the expression held in the
string str.

e.g

(setq str "(> 2 1)")

When str is "Eval"ed however you guys tell him to do it then this
expression will yield the value of the expression (> 2 1) which is, in
this case, 't.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]