Conflate Qnil and Qunbound for `symbol-function'.
* src/alloc.c (Fmake_symbol): Initialize `function' to Qnil. * src/lread.c (init_obarray): Set `function' fields to Qnil. * src/eval.c (Fcommandp): Ignore Qunbound. (Fautoload, eval_sub, Fapply, Ffuncall, Fmacroexpand): * src/data.c (Ffset, Ffboundp, indirect_function, Findirect_function): Test NILP rather than Qunbound. (Ffmakunbound): Set to Qnil. (Fsymbol_function): Never signal an error. (Finteractive_form): Ignore Qunbound.
This commit is contained in:
parent
2e31777bd1
commit
eadf1faa3c
7 changed files with 44 additions and 27 deletions
4
etc/NEWS
4
etc/NEWS
|
@ -52,6 +52,10 @@ It is layered as:
|
|||
|
||||
* Incompatible Lisp Changes in Emacs 24.4
|
||||
|
||||
** nil and "unbound" are indistinguishable in symbol-function.
|
||||
`symbol-function' never signals `void-function' any more.
|
||||
`fboundp' returns non-nil if the symbol was `fset' to nil.
|
||||
|
||||
** `defadvice' does not honor the `freeze' flag and cannot advise
|
||||
special-forms any more.
|
||||
|
||||
|
|
|
@ -1,3 +1,16 @@
|
|||
2012-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
|
||||
|
||||
Conflate Qnil and Qunbound for `symbol-function'.
|
||||
* alloc.c (Fmake_symbol): Initialize `function' to Qnil.
|
||||
* lread.c (init_obarray): Set `function' fields to Qnil.
|
||||
* eval.c (Fcommandp): Ignore Qunbound.
|
||||
(Fautoload, eval_sub, Fapply, Ffuncall, Fmacroexpand):
|
||||
* data.c (Ffset, Ffboundp, indirect_function, Findirect_function):
|
||||
Test NILP rather than Qunbound.
|
||||
(Ffmakunbound): Set to Qnil.
|
||||
(Fsymbol_function): Never signal an error.
|
||||
(Finteractive_form): Ignore Qunbound.
|
||||
|
||||
2012-11-20 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
* eval.c (interactive_p): Remove no-longer-used decl.
|
||||
|
|
|
@ -3212,7 +3212,7 @@ static struct Lisp_Symbol *symbol_free_list;
|
|||
|
||||
DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
|
||||
doc: /* Return a newly allocated uninterned symbol whose name is NAME.
|
||||
Its value and function definition are void, and its property list is nil. */)
|
||||
Its value is void, and its function definition and property list are nil. */)
|
||||
(Lisp_Object name)
|
||||
{
|
||||
register Lisp_Object val;
|
||||
|
@ -3249,7 +3249,7 @@ Its value and function definition are void, and its property list is nil. */)
|
|||
set_symbol_plist (val, Qnil);
|
||||
p->redirect = SYMBOL_PLAINVAL;
|
||||
SET_SYMBOL_VAL (p, Qunbound);
|
||||
set_symbol_function (val, Qunbound);
|
||||
set_symbol_function (val, Qnil);
|
||||
set_symbol_next (val, NULL);
|
||||
p->gcmarkbit = 0;
|
||||
p->interned = SYMBOL_UNINTERNED;
|
||||
|
|
21
src/data.c
21
src/data.c
|
@ -543,12 +543,13 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
|
|||
return (EQ (valcontents, Qunbound) ? Qnil : Qt);
|
||||
}
|
||||
|
||||
/* FIXME: Make it an alias for function-symbol! */
|
||||
DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0,
|
||||
doc: /* Return t if SYMBOL's function definition is not void. */)
|
||||
(register Lisp_Object symbol)
|
||||
{
|
||||
CHECK_SYMBOL (symbol);
|
||||
return EQ (XSYMBOL (symbol)->function, Qunbound) ? Qnil : Qt;
|
||||
return NILP (XSYMBOL (symbol)->function) ? Qnil : Qt;
|
||||
}
|
||||
|
||||
DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0,
|
||||
|
@ -564,14 +565,14 @@ Return SYMBOL. */)
|
|||
}
|
||||
|
||||
DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0,
|
||||
doc: /* Make SYMBOL's function definition be void.
|
||||
doc: /* Make SYMBOL's function definition be nil.
|
||||
Return SYMBOL. */)
|
||||
(register Lisp_Object symbol)
|
||||
{
|
||||
CHECK_SYMBOL (symbol);
|
||||
if (NILP (symbol) || EQ (symbol, Qt))
|
||||
xsignal1 (Qsetting_constant, symbol);
|
||||
set_symbol_function (symbol, Qunbound);
|
||||
set_symbol_function (symbol, Qnil);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
|
@ -580,9 +581,7 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
|
|||
(register Lisp_Object symbol)
|
||||
{
|
||||
CHECK_SYMBOL (symbol);
|
||||
if (!EQ (XSYMBOL (symbol)->function, Qunbound))
|
||||
return XSYMBOL (symbol)->function;
|
||||
xsignal1 (Qvoid_function, symbol);
|
||||
}
|
||||
|
||||
DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
|
||||
|
@ -613,7 +612,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
|
|||
|
||||
function = XSYMBOL (symbol)->function;
|
||||
|
||||
if (!NILP (Vautoload_queue) && !EQ (function, Qunbound))
|
||||
if (!NILP (Vautoload_queue) && !NILP (function))
|
||||
Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
|
||||
|
||||
if (AUTOLOADP (function))
|
||||
|
@ -714,7 +713,7 @@ Value, if non-nil, is a list \(interactive SPEC). */)
|
|||
{
|
||||
Lisp_Object fun = indirect_function (cmd); /* Check cycles. */
|
||||
|
||||
if (NILP (fun) || EQ (fun, Qunbound))
|
||||
if (NILP (fun))
|
||||
return Qnil;
|
||||
|
||||
/* Use an `interactive-form' property if present, analogous to the
|
||||
|
@ -2008,10 +2007,10 @@ indirect_function (register Lisp_Object object)
|
|||
|
||||
for (;;)
|
||||
{
|
||||
if (!SYMBOLP (hare) || EQ (hare, Qunbound))
|
||||
if (!SYMBOLP (hare) || NILP (hare))
|
||||
break;
|
||||
hare = XSYMBOL (hare)->function;
|
||||
if (!SYMBOLP (hare) || EQ (hare, Qunbound))
|
||||
if (!SYMBOLP (hare) || NILP (hare))
|
||||
break;
|
||||
hare = XSYMBOL (hare)->function;
|
||||
|
||||
|
@ -2038,10 +2037,10 @@ function chain of symbols. */)
|
|||
|
||||
/* Optimize for no indirection. */
|
||||
result = object;
|
||||
if (SYMBOLP (result) && !EQ (result, Qunbound)
|
||||
if (SYMBOLP (result) && !NILP (result)
|
||||
&& (result = XSYMBOL (result)->function, SYMBOLP (result)))
|
||||
result = indirect_function (result);
|
||||
if (!EQ (result, Qunbound))
|
||||
if (!NILP (result))
|
||||
return result;
|
||||
|
||||
if (NILP (noerror))
|
||||
|
|
24
src/eval.c
24
src/eval.c
|
@ -875,7 +875,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */)
|
|||
if (NILP (tem))
|
||||
{
|
||||
def = XSYMBOL (sym)->function;
|
||||
if (!EQ (def, Qunbound))
|
||||
if (!NILP (def))
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
@ -890,7 +890,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */)
|
|||
GCPRO1 (form);
|
||||
def = Fautoload_do_load (def, sym, Qmacro);
|
||||
UNGCPRO;
|
||||
if (EQ (def, Qunbound) || !CONSP (def))
|
||||
if (!CONSP (def))
|
||||
/* Not defined or definition not suitable. */
|
||||
break;
|
||||
if (!EQ (XCAR (def), Qmacro))
|
||||
|
@ -1715,12 +1715,12 @@ then strings and vectors are not accepted. */)
|
|||
|
||||
fun = function;
|
||||
|
||||
fun = indirect_function (fun); /* Check cycles. */
|
||||
if (NILP (fun) || EQ (fun, Qunbound))
|
||||
fun = indirect_function (fun); /* Check cycles. */
|
||||
if (NILP (fun))
|
||||
return Qnil;
|
||||
|
||||
/* Check an `interactive-form' property if present, analogous to the
|
||||
function-documentation property. */
|
||||
function-documentation property. */
|
||||
fun = function;
|
||||
while (SYMBOLP (fun))
|
||||
{
|
||||
|
@ -1780,7 +1780,7 @@ this does nothing and returns nil. */)
|
|||
CHECK_STRING (file);
|
||||
|
||||
/* If function is defined and not as an autoload, don't override. */
|
||||
if (!EQ (XSYMBOL (function)->function, Qunbound)
|
||||
if (!NILP (XSYMBOL (function)->function)
|
||||
&& !AUTOLOADP (XSYMBOL (function)->function))
|
||||
return Qnil;
|
||||
|
||||
|
@ -1959,7 +1959,7 @@ eval_sub (Lisp_Object form)
|
|||
|
||||
/* Optimize for no indirection. */
|
||||
fun = original_fun;
|
||||
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
|
||||
if (SYMBOLP (fun) && !NILP (fun)
|
||||
&& (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
|
||||
fun = indirect_function (fun);
|
||||
|
||||
|
@ -2081,7 +2081,7 @@ eval_sub (Lisp_Object form)
|
|||
val = apply_lambda (fun, original_args);
|
||||
else
|
||||
{
|
||||
if (EQ (fun, Qunbound))
|
||||
if (NILP (fun))
|
||||
xsignal1 (Qvoid_function, original_fun);
|
||||
if (!CONSP (fun))
|
||||
xsignal1 (Qinvalid_function, original_fun);
|
||||
|
@ -2155,10 +2155,10 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
|
|||
numargs += nargs - 2;
|
||||
|
||||
/* Optimize for no indirection. */
|
||||
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
|
||||
if (SYMBOLP (fun) && !NILP (fun)
|
||||
&& (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
|
||||
fun = indirect_function (fun);
|
||||
if (EQ (fun, Qunbound))
|
||||
if (NILP (fun))
|
||||
{
|
||||
/* Let funcall get the error. */
|
||||
fun = args[0];
|
||||
|
@ -2632,7 +2632,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
|
|||
|
||||
/* Optimize for no indirection. */
|
||||
fun = original_fun;
|
||||
if (SYMBOLP (fun) && !EQ (fun, Qunbound)
|
||||
if (SYMBOLP (fun) && !NILP (fun)
|
||||
&& (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
|
||||
fun = indirect_function (fun);
|
||||
|
||||
|
@ -2720,7 +2720,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
|
|||
val = funcall_lambda (fun, numargs, args + 1);
|
||||
else
|
||||
{
|
||||
if (EQ (fun, Qunbound))
|
||||
if (NILP (fun))
|
||||
xsignal1 (Qvoid_function, original_fun);
|
||||
if (!CONSP (fun))
|
||||
xsignal1 (Qinvalid_function, original_fun);
|
||||
|
|
|
@ -1104,7 +1104,7 @@ struct Lisp_Symbol
|
|||
union Lisp_Fwd *fwd;
|
||||
} val;
|
||||
|
||||
/* Function value of the symbol or Qunbound if not fboundp. */
|
||||
/* Function value of the symbol or Qnil if not fboundp. */
|
||||
Lisp_Object function;
|
||||
|
||||
/* The symbol's property list. */
|
||||
|
|
|
@ -3957,12 +3957,13 @@ init_obarray (void)
|
|||
/* Fmake_symbol inits fields of new symbols with Qunbound and Qnil,
|
||||
so those two need to be fixed manually. */
|
||||
SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound);
|
||||
set_symbol_function (Qunbound, Qunbound);
|
||||
set_symbol_function (Qunbound, Qnil);
|
||||
set_symbol_plist (Qunbound, Qnil);
|
||||
SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil);
|
||||
XSYMBOL (Qnil)->constant = 1;
|
||||
XSYMBOL (Qnil)->declared_special = 1;
|
||||
set_symbol_plist (Qnil, Qnil);
|
||||
set_symbol_function (Qnil, Qnil);
|
||||
|
||||
Qt = intern_c_string ("t");
|
||||
SET_SYMBOL_VAL (XSYMBOL (Qt), Qt);
|
||||
|
|
Loading…
Add table
Reference in a new issue