From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: eval trouble Date: Mon, 25 Aug 2008 21:48:44 +0200 Organization: Organization?!? Message-ID: <85od3g3mg3.fsf@lola.goethe.zz> References: <48B2E455.4060600@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1219696888 15584 80.91.229.12 (25 Aug 2008 20:41:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Aug 2008 20:41:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Aug 25 22:42:21 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 1KXitB-0006ll-0E for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Aug 2008 22:42:13 +0200 Original-Received: from localhost ([127.0.0.1]:49892 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KXisD-0000LF-4D for geh-help-gnu-emacs@m.gmane.org; Mon, 25 Aug 2008 16:41:13 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) Cancel-Lock: sha1:x7QeAmQjWEdVorhc3tsSowbTyI8= Original-Lines: 70 Original-NNTP-Posting-Date: 25 Aug 2008 21:48:45 CEST Original-NNTP-Posting-Host: b6b4a2a5.newsspool4.arcor-online.net Original-X-Trace: DXC=5K7k_:[1; MGX36K@\WTHGJ4IUK\BH3YB8\bgOS]^Z6ACV`H8_`hhQD^9QSCVg3dOFOIC5DBZVJ9K99]fSMeYDoGfV_X=\h_\3B Original-X-Complaints-To: usenet-abuse@arcor.de Original-Xref: news.stanford.edu gnu.emacs.help:161630 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:56973 Archived-At: "Lennart Borgman (gmail)" writes: > Lennart Borgman (gmail) wrote: >> I expected the code below to give me a function named >> mumamo-repl4-my-own9-mode. It does not. It does. It gives you a function named mumamo-repl4-my-own9-mode. It just does not make the name known to the world. A symbol has four cells: a function cell, a name, a value cell and a property list. And you can intern a symbol into an OBARRAY, which is sort of a hash references by name. The Lisp reader identifies names with symbols by looking them up in the global 'obarray. IIRC, there are no functions to change a symbol's name (which is fixed at creation time), and there is no way to enter a symbol into an obarray at any index except its fixed name. And you can only enter symbols into a single obarray at most, at creation time when you specify the symbol's name to "intern". If you don't want to enter it into any obarray, use make-symbol. The given symbol has a name, but you can't reference it by its name then. >> Can someone please explain what I am doing wrong? >> >> Interestingly if I do describe-variable on xx and then use the shown value t >> >> (setq xx THE-SHOWN-VALUE >> >> then >> >> (eval xx) >> >> does what I want. Sure, because you then store the symbol itself and don't need its name as a reference. >> Here is the code that does NOT work: >> >> (defun mumamo-define-no-mode (mode-sym) >> (let ((mumamo-repl4 (make-symbol (format "mumamo-repl4-%s" mode-sym))) > > It works if I replace make-symbol with intern. But why does eval care > about that? Because eval, when given the string "'mumamo-repl4-mode" will look up mumamo-repl4-mode in the global obarray, and there is nothing with that name in that obarray. A symbol with that name exists, but not referenced through its name. Each call of make-symbol creates a new symbol, like each call of list creates a new list. (eq (make-symbol "x") (make-symbol "x")) -> nil (eq (intern "x") 'x) -> t (make-symbol "x") -> x Note that the last line just prints the _name_ of the created symbol. It does not mean that you can use the name to get back the symbol, just like (eq 1.0 1.0) -> nil creates two different objects which are not EQ. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum