]> code.delx.au - gnu-emacs/commitdiff
Fix return value of `defun' and un-define it.
authorStefan Monnier <monnier@iro.umontreal.ca>
Mon, 18 Jun 2012 15:57:41 +0000 (11:57 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Mon, 18 Jun 2012 15:57:41 +0000 (11:57 -0400)
* src/data.c (Fdefalias): Return `symbol'.
* doc/lispref/functions.texi (Defining Functions):
* doc/lispref/macros.texi (Defining Macros): Un-define the return value of
`defun', `defmacro' and `defalias'.

Fixes: debbugs:11686
doc/lispref/ChangeLog
doc/lispref/functions.texi
doc/lispref/macros.texi
etc/NEWS
lisp/emacs-lisp/byte-run.el
src/ChangeLog
src/data.c

index 0439cf2be574d3a63da06989b2e6de7571f81234..89efb5c62554fe666ccdb9ff3d1ba7fa4c4b925a 100644 (file)
@@ -1,3 +1,9 @@
+2012-06-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * functions.texi (Defining Functions):
+       * macros.texi (Defining Macros): Un-define the return value of `defun',
+       `defmacro' and `defalias'.
+
 2012-06-17  Chong Yidong  <cyd@gnu.org>
 
        * elisp.texi: Remove urlcolor setting.
index 5fba243f65fd0e16d0e0d20c1ede70a8cf8b8585..ab2789b5e6d7718010de499bb24a5cec7ecda42f 100644 (file)
@@ -530,8 +530,7 @@ defines the symbol @var{name} as a function that looks like this:
 @end example
 
 @code{defun} stores this lambda expression in the function cell of
-@var{name}.  It returns the value @var{name}, but usually we ignore this
-value.
+@var{name}.  Its return value is @emph{undefined}.
 
 As described previously, @var{argument-list} is a list of argument
 names and may include the keywords @code{&optional} and @code{&rest}.
@@ -543,9 +542,6 @@ Here are some examples:
 @example
 @group
 (defun foo () 5)
-     @result{} foo
-@end group
-@group
 (foo)
      @result{} 5
 @end group
@@ -553,9 +549,6 @@ Here are some examples:
 @group
 (defun bar (a &optional b &rest c)
     (list a b c))
-     @result{} bar
-@end group
-@group
 (bar 1 2 3 4 5)
      @result{} (1 2 (3 4 5))
 @end group
@@ -576,7 +569,6 @@ Here are some examples:
   (forward-word 1)
   (backward-char 1)
   (capitalize-word 1))
-     @result{} capitalize-backwards
 @end group
 @end example
 
@@ -593,7 +585,7 @@ redefinition from unintentional redefinition.
 @anchor{Definition of defalias}
 This special form defines the symbol @var{name} as a function, with
 definition @var{definition} (which can be any valid Lisp function).
-It returns @var{definition}.
+Its return value is @emph{undefined}.
 
 If @var{docstring} is non-@code{nil}, it becomes the function
 documentation of @var{name}.  Otherwise, any documentation provided by
@@ -1015,9 +1007,6 @@ function.
 @example
 @group
 (defun bar (n) (+ n 2))
-     @result{} bar
-@end group
-@group
 (symbol-function 'bar)
      @result{} (lambda (n) (+ n 2))
 @end group
@@ -1063,9 +1052,6 @@ subsequent attempt to access this cell will cause a
 @example
 @group
 (defun foo (x) x)
-     @result{} foo
-@end group
-@group
 (foo 1)
      @result{}1
 @end group
index b9b0e03c65aa4f00a0295d84b975d8c517853c55..efe298bf647cf818bcc064f684fd2e5f3c097916 100644 (file)
@@ -113,7 +113,6 @@ uses this feature.
 @group
 (defmacro inc (var)
     (list 'setq var (list '1+ var)))
-     @result{} inc
 @end group
 
 @group
@@ -124,7 +123,6 @@ uses this feature.
 @group
 (defmacro inc2 (var1 var2)
     (list 'progn (list 'inc var1) (list 'inc var2)))
-     @result{} inc2
 @end group
 
 @group
@@ -207,9 +205,8 @@ like this:
 @end example
 
 (Note that the @sc{cdr} of this list is a function---a lambda expression.)
-This macro object is stored in the function cell of @var{name}.  The
-value returned by evaluating the @code{defmacro} form is @var{name}, but
-usually we ignore this value.
+This macro object is stored in the function cell of @var{name}.  Its return
+value is @emph{undefined}.
 
 The shape and meaning of @var{argument-list} is the same as in a
 function, and the keywords @code{&rest} and @code{&optional} may be used
@@ -342,7 +339,6 @@ For example, (for i from 1 to 10 do (print i))."
               (cons (list '<= var final)
                     (append body (list (list 'inc var)))))))
 @end group
-@result{} for
 
 @group
 (for i from 1 to 3 do
@@ -512,7 +508,6 @@ it.  Here is an example:
 @group
 (defmacro foo (a)
   (list 'setq (eval a) t))
-     @result{} foo
 @end group
 @group
 (setq x 'b)
index c469c7951ed93e0e55fdc89be36e0f08dbb340c8..629743bac4ef7613b300f07d44e5693d2a35fa43 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -429,6 +429,8 @@ still be supported for Emacs 24.x.
 \f
 * Lisp changes in Emacs 24.2
 
+** The return value of `defalias' has changed and is now undefined.
+
 ** `defun' also accepts a (declare DECLS) form, like `defmacro'.
 The interpretation of the DECLS is determined by `defun-declarations-alist'.
 
index 635eef93d9643ea930de89bbe3b82646e227e68e..925d275386f07cb8c3934e67099c06e778f84b6f 100644 (file)
@@ -123,7 +123,8 @@ the list ARGS... as it appears in the expression,
 and the result should be a form to be evaluated instead of the original.
 DECL is a declaration, optional, of the form (declare DECLS...) where
 DECLS is a list of elements of the form (PROP . VALUES).  These are
-interpreted according to `macro-declarations-alist'."
+interpreted according to `macro-declarations-alist'.
+The return value is undefined."
        (if (stringp docstring) nil
          (if decl (setq body (cons decl body)))
          (setq decl docstring)
@@ -158,6 +159,7 @@ See also the function `interactive'.
 DECL is a declaration, optional, of the form (declare DECLS...) where
 DECLS is a list of elements of the form (PROP . VALUES).  These are
 interpreted according to `defun-declarations-alist'.
+The return value is undefined.
 
 \(fn NAME ARGLIST &optional DOCSTRING DECL &rest BODY)"
   ;; We can't just have `decl' as an &optional argument, because we need
index 9a239de5b998876a85b527667680d71f97f6170a..080748236b494e59dc0b006e0ad773e4cec30b0f 100644 (file)
@@ -1,8 +1,12 @@
+2012-06-18  Stefan Monnier  <monnier@iro.umontreal.ca>
+
+       * data.c (Fdefalias): Return `symbol' (bug#11686).
+
 2012-06-18  Martin Rudalics  <rudalics@gmx.at>
 
        * buffer.c (Fkill_buffer): Don't throw an error when the buffer
-       gets killed during executing of this function (Bug#11665).  Try
-       to always return Qt when the buffer has been actually killed.
+       gets killed during executing of this function (Bug#11665).
+       Try to always return Qt when the buffer has been actually killed.
        (Vkill_buffer_query_functions): In doc-string say that functions
        run by this hook should not change the current buffer.
 
@@ -56,8 +60,8 @@
        (x_draw_glyph_string): Use them.
        * xfaces.c (Qline, Qwave): New Lisp objects.
        (check_lface_attrs, merge_face_ref)
-       (Finternal_set_lisp_face_attribute, realize_x_face): Handle
-       wave-style underline face attributes.
+       (Finternal_set_lisp_face_attribute, realize_x_face):
+       Handle wave-style underline face attributes.
        * xterm.c (x_draw_underwave): New function.
        (x_draw_glyph_string): Use it.
 
 
 2012-06-16  Eli Zaretskii  <eliz@gnu.org>
 
-       * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end.  If
-       all the glyphs of the glyph row came from strings, and we have no
+       * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end.
+       If all the glyphs of the glyph row came from strings, and we have no
        cursor positioning clues, put the cursor on the first glyph of the
        row.
        (handle_face_prop): Use chunk-relative overlay string index when
        Simplify under the assumption that USE_2_TAGS_FOR_INTS is defined.
        (INTTYPEBITS): New macro, for clarity.
        (INTMASK, MOST_POSITIVE_FIXNUM): Use it.
-       (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P): Simplify
-       now that USE_LSB_TAG is always defined.
+       (LISP_INT1_TAG, LISP_STRING_TAG, LISP_INT_TAG_P):
+       Simplify now that USE_LSB_TAG is always defined.
        (TYPEMASK, XINT) [USE_LSB_TAG]: Remove unnecessary cast.
        (make_number) [!USE_LSB_TAG]: Use INTMASK; that's simpler.
 
        * lisp.h (Lisp_Object) [CHECK_LISP_OBJECT_TYPE]: Define as struct
        instead of union.
        (XLI, XIL): Define.
-       (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG): Use
-       them.
-       * emacs.c (gdb_use_struct): Renamed from gdb_use_union.
+       (XHASH, XTYPE, XINT, XUINT, make_number, XSET, XPNTR, XUNTAG):
+       Use them.
+       * emacs.c (gdb_use_struct): Rename from gdb_use_union.
        * .gdbinit: Check gdb_use_struct instead of gdb_use_union.
-       * alloc.c (widen_to_Lisp_Object): Removed.
+       * alloc.c (widen_to_Lisp_Object): Remove.
        (mark_memory): Use XIL instead of widen_to_Lisp_Object.
        * frame.c (delete_frame): Remove outdated comment.
        * w32fns.c (Fw32_register_hot_key): Use XLI instead of checking
index 4449977dbe02ecc10e32a14426b4debf6a8afeac..2aa27e65d7729c65c1da51061eeadb73d872a5af 100644 (file)
@@ -637,8 +637,9 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
     Fput (symbol, Qautoload, XCDR (function));
 
   XSYMBOL (symbol)->function = definition;
-  /* Handle automatic advice activation */
-  if (CONSP (XSYMBOL (symbol)->plist) && !NILP (Fget (symbol, Qad_advice_info)))
+  /* Handle automatic advice activation.  */
+  if (CONSP (XSYMBOL (symbol)->plist)
+      && !NILP (Fget (symbol, Qad_advice_info)))
     {
       call2 (Qad_activate_internal, symbol, Qnil);
       definition = XSYMBOL (symbol)->function;
@@ -647,11 +648,12 @@ DEFUN ("fset", Ffset, Sfset, 2, 2, 0,
 }
 
 DEFUN ("defalias", Fdefalias, Sdefalias, 2, 3, 0,
-       doc: /* Set SYMBOL's function definition to DEFINITION, and return DEFINITION.
+       doc: /* Set SYMBOL's function definition to DEFINITION.
 Associates the function with the current load file, if any.
 The optional third argument DOCSTRING specifies the documentation string
 for SYMBOL; if it is omitted or nil, SYMBOL uses the documentation string
-determined by DEFINITION.  */)
+determined by DEFINITION.
+The return value is undefined.  */)
   (register Lisp_Object symbol, Lisp_Object definition, Lisp_Object docstring)
 {
   CHECK_SYMBOL (symbol);
@@ -666,7 +668,10 @@ determined by DEFINITION.  */)
   LOADHIST_ATTACH (Fcons (Qdefun, symbol));
   if (!NILP (docstring))
     Fput (symbol, Qfunction_documentation, docstring);
-  return definition;
+  /* We used to return `definition', but now that `defun' and `defmacro' expand
+     to a call to `defalias', we return `symbol' for backward compatibility
+     (bug#11686).  */
+  return symbol;
 }
 
 DEFUN ("setplist", Fsetplist, Ssetplist, 2, 2, 0,