For 21.4 and 21.5. This is safe.
>>>> "KY" == Katsumi Yamaoka
<yamaoka(a)jpl.org> writes:
KY> Please evaluate the following four Lisp forms one by one:
KY> (defun hello-world () "Hello World")
KY> (hello-world)
KY> (byte-compile 'hello-world)
KY> (hello-world)
KY> I got the string "Hello World" by the second form, but nil by
KY> the fourth form. I am at a loss for words...
I really never wanted to learn about the byte compiler....
This should be OK, it turns out that GNU Emacs uses exactly the same
test in that function. Since 1996. :-(
Index: lisp/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/ChangeLog,v
retrieving revision 1.509
diff -u -U0 -r1.509 ChangeLog
--- lisp/ChangeLog 1 Jun 2003 05:10:19 -0000 1.509
+++ lisp/ChangeLog 17 Jun 2003 10:14:03 -0000
@@ -0,0 +1,5 @@
+2003-06-17 Stephen J. Turnbull <stephen(a)xemacs.org>
+
+ * bytecomp.el (byte-compile-lambda): Discard docstring only if it
+ is not also the value of the lambda.
+
Index: lisp/bytecomp.el
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lisp/bytecomp.el,v
retrieving revision 1.16
diff -u -r1.16 bytecomp.el
--- lisp/bytecomp.el 20 Feb 2003 08:19:29 -0000 1.16
+++ lisp/bytecomp.el 17 Jun 2003 10:14:11 -0000
@@ -2453,7 +2453,10 @@
(body (cdr (cdr fun)))
(doc (if (stringp (car body))
(prog1 (car body)
- (setq body (cdr body)))))
+ ;; Discard the doc string
+ ;; only if it is not the only element of the body.
+ (if (cdr body)
+ (setq body (cdr body))))))
(int (assq 'interactive body)))
(dolist (arg arglist)
(cond ((not (symbolp arg))
--
Institute of Policy and Planning Sciences
http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
Ask not how you can "do" free software business;
ask what your business can "do for" free software.