[Top][All Lists]

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

Re: when you gotta have a variable value for a symbol name

From: Robert Thorpe
Subject: Re: when you gotta have a variable value for a symbol name
Date: Thu, 24 Jul 2014 22:57:24 +0100

Drew Adams <address@hidden> 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

(info "(elisp) Symbols")

Robert Thorpe

reply via email to

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