From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Robert Thorpe Newsgroups: gmane.emacs.help Subject: Re: when you gotta have a variable value for a symbol name Date: Thu, 24 Jul 2014 22:57:24 +0100 Message-ID: <877g322zej.fsf@robertthorpeconsulting.com> References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1406239081 6047 80.91.229.3 (24 Jul 2014 21:58:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jul 2014 21:58:01 +0000 (UTC) Cc: buchs.kevin@mayo.edu, help-gnu-emacs@gnu.org To: Drew Adams Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 24 23:57:54 2014 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XAR1N-0005Ah-13 for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Jul 2014 23:57:53 +0200 Original-Received: from localhost ([::1]:52283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAR1M-00055a-I9 for geh-help-gnu-emacs@m.gmane.org; Thu, 24 Jul 2014 17:57:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58493) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAR16-00055Q-4J for help-gnu-emacs@gnu.org; Thu, 24 Jul 2014 17:57:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAR0y-0000QG-Nz for help-gnu-emacs@gnu.org; Thu, 24 Jul 2014 17:57:36 -0400 Original-Received: from outbound-smtp06.blacknight.com ([81.17.249.39]:46943) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAR0y-0000QC-IE for help-gnu-emacs@gnu.org; Thu, 24 Jul 2014 17:57:28 -0400 Original-Received: from mail.blacknight.com (pemlinmail01.blacknight.ie [81.17.254.10]) by outbound-smtp06.blacknight.com (Postfix) with ESMTP id 2A80398506 for ; Thu, 24 Jul 2014 21:57:04 +0000 (UTC) Original-Received: (qmail 5402 invoked from network); 24 Jul 2014 21:57:26 -0000 Original-Received: from unknown (HELO RTLaptop) (rt@robertthorpeconsulting.com@[109.76.108.62]) by 81.17.254.9 with ESMTPSA (DHE-RSA-AES128-SHA encrypted, authenticated); 24 Jul 2014 21:57:26 -0000 In-Reply-To: (message from Drew Adams on Wed, 23 Jul 2014 15:02:38 -0700 (PDT)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 81.17.249.39 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:98934 Archived-At: Drew Adams writes: >> I want to evaluate (kmacro-name-last-macro variable), where I want the >> value of "variable" passed as the symbol name. Despite years of trying, >> I don't think I ever really conceptually "got" the distinction between >> symbols and variables and that seems to be critical here. I'm working >> with the code below, but it is not suceeding in naming the macros (no >> error messages, however). Of course (kmacro-name-last-macro 'my-macro) >> works just fine. Lisp is like the insides of a compiler. There's a big hash-map, the obarray, which is the symbol-table. It stores strings along with some information about them. These strings are "symbols". There are three pieces of information: the symbol's value as a variable, the symbols value as a function and a property list. An interned symbol is one that is an entry in the obarray (there can be multiple obarrays though that feature isn't used much). An uninterned symbol is one that sits by itself, it has the same parts as usual: string, function entry, variable entry and plist, but it's not attached to an obarray. If we have a function call: (foo bar 'baz) then lisp treats each of these symbols differently. It finds the function slot for foo because that's the first symbol, it finds the variable slot for bar because it's not first. Finally, 'baz returns the symbol itself. To be more careful: (quote baz) returns a list containing the symbol, which evaluates to the symbol. (info "(elisp) Symbols") BR, Robert Thorpe