From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: how to convert a string to a symbol? Date: Sun, 14 Sep 2008 09:25:45 +0200 Organization: Informatimago Message-ID: <87od2r89za.fsf@hubble.informatimago.com> References: <003701c9162e$58cfcd50$0200a8c0@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1221378111 18941 80.91.229.12 (14 Sep 2008 07:41:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 14 Sep 2008 07:41:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Sep 14 09:42:47 2008 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KemFn-00063G-UG for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Sep 2008 09:42:44 +0200 Original-Received: from localhost ([127.0.0.1]:60354 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KemEn-0005Fn-EJ for geh-help-gnu-emacs@m.gmane.org; Sun, 14 Sep 2008 03:41:41 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.fjserv.net!oleane.net!oleane!news.in2p3.fr!in2p3.fr!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!cleanfeed3-a.proxad.net!nnrp11-2.free.fr!not-for-mail Original-Newsgroups: gnu.emacs.help Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:+edIrMmyRwmAg8dTQEqH2+wJtUI= Original-Lines: 42 Original-NNTP-Posting-Date: 14 Sep 2008 09:25:46 MEST Original-NNTP-Posting-Host: 88.182.134.169 Original-X-Trace: 1221377146 news-2.free.fr 9617 88.182.134.169:47827 Original-X-Complaints-To: abuse@proxad.net Original-Xref: news.stanford.edu gnu.emacs.help:162215 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:57558 Archived-At: "Drew Adams" 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)... sunways, what Drew tries to hint at is that you don't want string-to-symbol. (By the way, there's another way to get a symbol from a string, it's make-symbol, but it makes an uninterned symbol, which is even less what you want). So as you may have realized by now, what you want is to get the symbolic expression, or s-exp (> 2 1) from "(> 2 1)", and this can be done by "reading" the string, so, logically, with read-from-string. (car (read-from-string "(> 2 1)")) -> (> 2 1) Now the question would be where did you get this string from in the first place? You probably could have used read, or specified you wanted a s-exp instead of a string at the source. -- __Pascal Bourguignon__ http://www.informatimago.com/ You never feed me. Perhaps I'll sleep on your face. That will sure show you.