aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2012-11-20 15:06:17 -0500
committerStefan Monnier2012-11-20 15:06:17 -0500
commiteadf1faa3cb5eea8c25a5166a9a97ebd63525c56 (patch)
treec5b92de52e664400cbc79f7dd344cbf440fb7e2a /src
parent2e31777bd1354d22319cf6de4085ccc362cff42c (diff)
downloademacs-eadf1faa3cb5eea8c25a5166a9a97ebd63525c56.tar.gz
emacs-eadf1faa3cb5eea8c25a5166a9a97ebd63525c56.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog13
-rw-r--r--src/alloc.c4
-rw-r--r--src/data.c21
-rw-r--r--src/eval.c24
-rw-r--r--src/lisp.h2
-rw-r--r--src/lread.c3
6 files changed, 40 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9a2cec8a7fc..332656fcf00 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
12012-11-20 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 Conflate Qnil and Qunbound for `symbol-function'.
4 * alloc.c (Fmake_symbol): Initialize `function' to Qnil.
5 * lread.c (init_obarray): Set `function' fields to Qnil.
6 * eval.c (Fcommandp): Ignore Qunbound.
7 (Fautoload, eval_sub, Fapply, Ffuncall, Fmacroexpand):
8 * data.c (Ffset, Ffboundp, indirect_function, Findirect_function):
9 Test NILP rather than Qunbound.
10 (Ffmakunbound): Set to Qnil.
11 (Fsymbol_function): Never signal an error.
12 (Finteractive_form): Ignore Qunbound.
13
12012-11-20 Paul Eggert <eggert@cs.ucla.edu> 142012-11-20 Paul Eggert <eggert@cs.ucla.edu>
2 15
3 * eval.c (interactive_p): Remove no-longer-used decl. 16 * eval.c (interactive_p): Remove no-longer-used decl.
diff --git a/src/alloc.c b/src/alloc.c
index a66a752f5dc..22e3db3cc77 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -3212,7 +3212,7 @@ static struct Lisp_Symbol *symbol_free_list;
3212 3212
3213DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0, 3213DEFUN ("make-symbol", Fmake_symbol, Smake_symbol, 1, 1, 0,
3214 doc: /* Return a newly allocated uninterned symbol whose name is NAME. 3214 doc: /* Return a newly allocated uninterned symbol whose name is NAME.
3215Its value and function definition are void, and its property list is nil. */) 3215Its value is void, and its function definition and property list are nil. */)
3216 (Lisp_Object name) 3216 (Lisp_Object name)
3217{ 3217{
3218 register Lisp_Object val; 3218 register Lisp_Object val;
@@ -3249,7 +3249,7 @@ Its value and function definition are void, and its property list is nil. */)
3249 set_symbol_plist (val, Qnil); 3249 set_symbol_plist (val, Qnil);
3250 p->redirect = SYMBOL_PLAINVAL; 3250 p->redirect = SYMBOL_PLAINVAL;
3251 SET_SYMBOL_VAL (p, Qunbound); 3251 SET_SYMBOL_VAL (p, Qunbound);
3252 set_symbol_function (val, Qunbound); 3252 set_symbol_function (val, Qnil);
3253 set_symbol_next (val, NULL); 3253 set_symbol_next (val, NULL);
3254 p->gcmarkbit = 0; 3254 p->gcmarkbit = 0;
3255 p->interned = SYMBOL_UNINTERNED; 3255 p->interned = SYMBOL_UNINTERNED;
diff --git a/src/data.c b/src/data.c
index 09899400b68..5fc6afaaa03 100644
--- a/src/data.c
+++ b/src/data.c
@@ -543,12 +543,13 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
543 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 543 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
544} 544}
545 545
546/* FIXME: Make it an alias for function-symbol! */
546DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0, 547DEFUN ("fboundp", Ffboundp, Sfboundp, 1, 1, 0,
547 doc: /* Return t if SYMBOL's function definition is not void. */) 548 doc: /* Return t if SYMBOL's function definition is not void. */)
548 (register Lisp_Object symbol) 549 (register Lisp_Object symbol)
549{ 550{
550 CHECK_SYMBOL (symbol); 551 CHECK_SYMBOL (symbol);
551 return EQ (XSYMBOL (symbol)->function, Qunbound) ? Qnil : Qt; 552 return NILP (XSYMBOL (symbol)->function) ? Qnil : Qt;
552} 553}
553 554
554DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0, 555DEFUN ("makunbound", Fmakunbound, Smakunbound, 1, 1, 0,
@@ -564,14 +565,14 @@ Return SYMBOL. */)
564} 565}
565 566
566DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0, 567DEFUN ("fmakunbound", Ffmakunbound, Sfmakunbound, 1, 1, 0,
567 doc: /* Make SYMBOL's function definition be void. 568 doc: /* Make SYMBOL's function definition be nil.
568Return SYMBOL. */) 569Return SYMBOL. */)
569 (register Lisp_Object symbol) 570 (register Lisp_Object symbol)
570{ 571{
571 CHECK_SYMBOL (symbol); 572 CHECK_SYMBOL (symbol);
572 if (NILP (symbol) || EQ (symbol, Qt)) 573 if (NILP (symbol) || EQ (symbol, Qt))
573 xsignal1 (Qsetting_constant, symbol); 574 xsignal1 (Qsetting_constant, symbol);
574 set_symbol_function (symbol, Qunbound); 575 set_symbol_function (symbol, Qnil);
575 return symbol; 576 return symbol;
576} 577}
577 578
@@ -580,9 +581,7 @@ DEFUN ("symbol-function", Fsymbol_function, Ssymbol_function, 1, 1, 0,
580 (register Lisp_Object symbol) 581 (register Lisp_Object symbol)
581{ 582{
582 CHECK_SYMBOL (symbol); 583 CHECK_SYMBOL (symbol);
583 if (!EQ (XSYMBOL (symbol)->function, Qunbound))
584 return XSYMBOL (symbol)->function; 584 return XSYMBOL (symbol)->function;
585 xsignal1 (Qvoid_function, symbol);
586} 585}
587 586
588DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0, 587DEFUN ("symbol-plist", Fsymbol_plist, Ssymbol_plist, 1, 1, 0,
@@ -613,7 +612,7 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
613 612
614 function = XSYMBOL (symbol)->function; 613 function = XSYMBOL (symbol)->function;
615 614
616 if (!NILP (Vautoload_queue) && !EQ (function, Qunbound)) 615 if (!NILP (Vautoload_queue) && !NILP (function))
617 Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue); 616 Vautoload_queue = Fcons (Fcons (symbol, function), Vautoload_queue);
618 617
619 if (AUTOLOADP (function)) 618 if (AUTOLOADP (function))
@@ -714,7 +713,7 @@ Value, if non-nil, is a list \(interactive SPEC). */)
714{ 713{
715 Lisp_Object fun = indirect_function (cmd); /* Check cycles. */ 714 Lisp_Object fun = indirect_function (cmd); /* Check cycles. */
716 715
717 if (NILP (fun) || EQ (fun, Qunbound)) 716 if (NILP (fun))
718 return Qnil; 717 return Qnil;
719 718
720 /* Use an `interactive-form' property if present, analogous to the 719 /* Use an `interactive-form' property if present, analogous to the
@@ -2008,10 +2007,10 @@ indirect_function (register Lisp_Object object)
2008 2007
2009 for (;;) 2008 for (;;)
2010 { 2009 {
2011 if (!SYMBOLP (hare) || EQ (hare, Qunbound)) 2010 if (!SYMBOLP (hare) || NILP (hare))
2012 break; 2011 break;
2013 hare = XSYMBOL (hare)->function; 2012 hare = XSYMBOL (hare)->function;
2014 if (!SYMBOLP (hare) || EQ (hare, Qunbound)) 2013 if (!SYMBOLP (hare) || NILP (hare))
2015 break; 2014 break;
2016 hare = XSYMBOL (hare)->function; 2015 hare = XSYMBOL (hare)->function;
2017 2016
@@ -2038,10 +2037,10 @@ function chain of symbols. */)
2038 2037
2039 /* Optimize for no indirection. */ 2038 /* Optimize for no indirection. */
2040 result = object; 2039 result = object;
2041 if (SYMBOLP (result) && !EQ (result, Qunbound) 2040 if (SYMBOLP (result) && !NILP (result)
2042 && (result = XSYMBOL (result)->function, SYMBOLP (result))) 2041 && (result = XSYMBOL (result)->function, SYMBOLP (result)))
2043 result = indirect_function (result); 2042 result = indirect_function (result);
2044 if (!EQ (result, Qunbound)) 2043 if (!NILP (result))
2045 return result; 2044 return result;
2046 2045
2047 if (NILP (noerror)) 2046 if (NILP (noerror))
diff --git a/src/eval.c b/src/eval.c
index 053b1a7f097..34b20f6fc8e 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -875,7 +875,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */)
875 if (NILP (tem)) 875 if (NILP (tem))
876 { 876 {
877 def = XSYMBOL (sym)->function; 877 def = XSYMBOL (sym)->function;
878 if (!EQ (def, Qunbound)) 878 if (!NILP (def))
879 continue; 879 continue;
880 } 880 }
881 break; 881 break;
@@ -890,7 +890,7 @@ definitions to shadow the loaded ones for use in file byte-compilation. */)
890 GCPRO1 (form); 890 GCPRO1 (form);
891 def = Fautoload_do_load (def, sym, Qmacro); 891 def = Fautoload_do_load (def, sym, Qmacro);
892 UNGCPRO; 892 UNGCPRO;
893 if (EQ (def, Qunbound) || !CONSP (def)) 893 if (!CONSP (def))
894 /* Not defined or definition not suitable. */ 894 /* Not defined or definition not suitable. */
895 break; 895 break;
896 if (!EQ (XCAR (def), Qmacro)) 896 if (!EQ (XCAR (def), Qmacro))
@@ -1715,12 +1715,12 @@ then strings and vectors are not accepted. */)
1715 1715
1716 fun = function; 1716 fun = function;
1717 1717
1718 fun = indirect_function (fun); /* Check cycles. */ 1718 fun = indirect_function (fun); /* Check cycles. */
1719 if (NILP (fun) || EQ (fun, Qunbound)) 1719 if (NILP (fun))
1720 return Qnil; 1720 return Qnil;
1721 1721
1722 /* Check an `interactive-form' property if present, analogous to the 1722 /* Check an `interactive-form' property if present, analogous to the
1723 function-documentation property. */ 1723 function-documentation property. */
1724 fun = function; 1724 fun = function;
1725 while (SYMBOLP (fun)) 1725 while (SYMBOLP (fun))
1726 { 1726 {
@@ -1780,7 +1780,7 @@ this does nothing and returns nil. */)
1780 CHECK_STRING (file); 1780 CHECK_STRING (file);
1781 1781
1782 /* If function is defined and not as an autoload, don't override. */ 1782 /* If function is defined and not as an autoload, don't override. */
1783 if (!EQ (XSYMBOL (function)->function, Qunbound) 1783 if (!NILP (XSYMBOL (function)->function)
1784 && !AUTOLOADP (XSYMBOL (function)->function)) 1784 && !AUTOLOADP (XSYMBOL (function)->function))
1785 return Qnil; 1785 return Qnil;
1786 1786
@@ -1959,7 +1959,7 @@ eval_sub (Lisp_Object form)
1959 1959
1960 /* Optimize for no indirection. */ 1960 /* Optimize for no indirection. */
1961 fun = original_fun; 1961 fun = original_fun;
1962 if (SYMBOLP (fun) && !EQ (fun, Qunbound) 1962 if (SYMBOLP (fun) && !NILP (fun)
1963 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) 1963 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
1964 fun = indirect_function (fun); 1964 fun = indirect_function (fun);
1965 1965
@@ -2081,7 +2081,7 @@ eval_sub (Lisp_Object form)
2081 val = apply_lambda (fun, original_args); 2081 val = apply_lambda (fun, original_args);
2082 else 2082 else
2083 { 2083 {
2084 if (EQ (fun, Qunbound)) 2084 if (NILP (fun))
2085 xsignal1 (Qvoid_function, original_fun); 2085 xsignal1 (Qvoid_function, original_fun);
2086 if (!CONSP (fun)) 2086 if (!CONSP (fun))
2087 xsignal1 (Qinvalid_function, original_fun); 2087 xsignal1 (Qinvalid_function, original_fun);
@@ -2155,10 +2155,10 @@ usage: (apply FUNCTION &rest ARGUMENTS) */)
2155 numargs += nargs - 2; 2155 numargs += nargs - 2;
2156 2156
2157 /* Optimize for no indirection. */ 2157 /* Optimize for no indirection. */
2158 if (SYMBOLP (fun) && !EQ (fun, Qunbound) 2158 if (SYMBOLP (fun) && !NILP (fun)
2159 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) 2159 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
2160 fun = indirect_function (fun); 2160 fun = indirect_function (fun);
2161 if (EQ (fun, Qunbound)) 2161 if (NILP (fun))
2162 { 2162 {
2163 /* Let funcall get the error. */ 2163 /* Let funcall get the error. */
2164 fun = args[0]; 2164 fun = args[0];
@@ -2632,7 +2632,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2632 2632
2633 /* Optimize for no indirection. */ 2633 /* Optimize for no indirection. */
2634 fun = original_fun; 2634 fun = original_fun;
2635 if (SYMBOLP (fun) && !EQ (fun, Qunbound) 2635 if (SYMBOLP (fun) && !NILP (fun)
2636 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun))) 2636 && (fun = XSYMBOL (fun)->function, SYMBOLP (fun)))
2637 fun = indirect_function (fun); 2637 fun = indirect_function (fun);
2638 2638
@@ -2720,7 +2720,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2720 val = funcall_lambda (fun, numargs, args + 1); 2720 val = funcall_lambda (fun, numargs, args + 1);
2721 else 2721 else
2722 { 2722 {
2723 if (EQ (fun, Qunbound)) 2723 if (NILP (fun))
2724 xsignal1 (Qvoid_function, original_fun); 2724 xsignal1 (Qvoid_function, original_fun);
2725 if (!CONSP (fun)) 2725 if (!CONSP (fun))
2726 xsignal1 (Qinvalid_function, original_fun); 2726 xsignal1 (Qinvalid_function, original_fun);
diff --git a/src/lisp.h b/src/lisp.h
index 67ae28a488f..4817c6eb990 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -1104,7 +1104,7 @@ struct Lisp_Symbol
1104 union Lisp_Fwd *fwd; 1104 union Lisp_Fwd *fwd;
1105 } val; 1105 } val;
1106 1106
1107 /* Function value of the symbol or Qunbound if not fboundp. */ 1107 /* Function value of the symbol or Qnil if not fboundp. */
1108 Lisp_Object function; 1108 Lisp_Object function;
1109 1109
1110 /* The symbol's property list. */ 1110 /* The symbol's property list. */
diff --git a/src/lread.c b/src/lread.c
index 5859a2f85a9..6d0ff9f780e 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -3957,12 +3957,13 @@ init_obarray (void)
3957 /* Fmake_symbol inits fields of new symbols with Qunbound and Qnil, 3957 /* Fmake_symbol inits fields of new symbols with Qunbound and Qnil,
3958 so those two need to be fixed manually. */ 3958 so those two need to be fixed manually. */
3959 SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound); 3959 SET_SYMBOL_VAL (XSYMBOL (Qunbound), Qunbound);
3960 set_symbol_function (Qunbound, Qunbound); 3960 set_symbol_function (Qunbound, Qnil);
3961 set_symbol_plist (Qunbound, Qnil); 3961 set_symbol_plist (Qunbound, Qnil);
3962 SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil); 3962 SET_SYMBOL_VAL (XSYMBOL (Qnil), Qnil);
3963 XSYMBOL (Qnil)->constant = 1; 3963 XSYMBOL (Qnil)->constant = 1;
3964 XSYMBOL (Qnil)->declared_special = 1; 3964 XSYMBOL (Qnil)->declared_special = 1;
3965 set_symbol_plist (Qnil, Qnil); 3965 set_symbol_plist (Qnil, Qnil);
3966 set_symbol_function (Qnil, Qnil);
3966 3967
3967 Qt = intern_c_string ("t"); 3968 Qt = intern_c_string ("t");
3968 SET_SYMBOL_VAL (XSYMBOL (Qt), Qt); 3969 SET_SYMBOL_VAL (XSYMBOL (Qt), Qt);