From unknown Thu Aug 21 12:10:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21690: (/ N) should return the reciprocal of N Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Oct 2015 19:12:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21690 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: 21690@debbugs.gnu.org X-Debbugs-Original-To: GNU Emacs bug reports Received: via spool by submit@debbugs.gnu.org id=B.144493628228788 (code B ref -1); Thu, 15 Oct 2015 19:12:01 +0000 Received: (at submit) by debbugs.gnu.org; 15 Oct 2015 19:11:22 +0000 Received: from localhost ([127.0.0.1]:52619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmnvt-0007UF-Jh for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55273) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmnvq-0007U6-Ou for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmnvo-0003mX-V4 for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:40804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvo-0003mK-Ry for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvm-0004VU-Bh for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmnvi-0003kR-7H for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:14 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvh-0003kK-VB for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B5FA7160CB6 for ; Thu, 15 Oct 2015 12:11:08 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id V1RkKB99VL9X for ; Thu, 15 Oct 2015 12:11:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EA793160D3D for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BLA-w24GGdby for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id AD4C1160CB6 for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <561FFA47.6020401@cs.ucla.edu> Date: Thu, 15 Oct 2015 12:11:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080800050905010008050404" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This is a multi-part message in MIME format. --------------080800050905010008050404 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Tags: patch The attached proposed patch is a followup to the recent discussion on emacs-devel. We're in feature-freeze now, so it's not a good time to apply it. Although I'm sympathetic to Stefan's point that the Common Lisp behavior is less logical, it is more useful in practice (as can be seen from some uses in the proposed patch) and there is a benefit to being compatible with CL. --------------080800050905010008050404 Content-Type: text/x-patch; name="0001-N-now-returns-the-reciprocal-of-N.patch" Content-Disposition: attachment; filename="0001-N-now-returns-the-reciprocal-of-N.patch" Content-Transfer-Encoding: quoted-printable >From b512e3a7a814eba4f09c11c3aad6d96ea6d0ae7c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 15 Oct 2015 12:05:35 -0700 Subject: [PATCH] (/ N) now returns the reciprocal of N MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This is more compatible with Common Lisp and with XEmacs. See: http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01053.html * lisp/color.el (color-hue-to-rgb, color-hsl-to-rgb) (color-xyz-to-srgb, color-xyz-to-lab): * lisp/emacs-lisp/cl-extra.el (cl-float-limits): * lisp/net/shr-color.el (shr-color-hue-to-rgb) (shr-color-hsl-to-rgb-fractions): Exploit the change to simplify the code a bit. * lisp/emacs-lisp/bytecomp.el (byte-compile-quo): Don=E2=80=99t complain about single-argument calls to =E2=80=98/=E2=80=99= . * src/data.c (arith_driver, float_arith_driver): Implement the change. --- doc/lispref/numbers.texi | 17 +++++++++++++---- etc/NEWS | 6 ++++++ lisp/color.el | 18 +++++++++--------- lisp/emacs-lisp/bytecomp.el | 4 ++-- lisp/emacs-lisp/cl-extra.el | 2 +- lisp/net/shr-color.el | 6 +++--- src/data.c | 11 +++++++---- 7 files changed, 41 insertions(+), 23 deletions(-) diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 3c70d2f..54c8d3e 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -642,10 +642,11 @@ Arithmetic Operations @end example @end defun =20 -@defun / dividend divisor &rest divisors -This function divides @var{dividend} by @var{divisor} and returns the -quotient. If there are additional arguments @var{divisors}, then it -divides @var{dividend} by each divisor in turn. Each argument may be a +@defun / number &rest divisors +With one or more @var{divisors}, this function divides @var{number} +by each divisor in @var{divisors} in turn, and returns the quotient. +With no @var{divisors}, this function returns 1/@var{number}, i.e., +the multiplicative inverse of @var{number}. Each argument may be a number or a marker. =20 If all the arguments are integers, the result is an integer, obtained @@ -673,6 +674,14 @@ Arithmetic Operations @result{} 2.5 @end group @group +(/ 4.0) + @result{} 0.25 +@end group +@group +(/ 4) + @result{} 0 +@end group +@group (/ 25 3 2) @result{} 4 @end group diff --git a/etc/NEWS b/etc/NEWS index dbe0de3..8170c4a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1007,6 +1007,12 @@ dynamically. dynamically. Any third-party code that changes these templates should be updated accordingly. =20 ++++ +** =E2=80=98(/ N)=E2=80=99 is now equivalent to =E2=80=98(/ 1 N)=E2=80=99= rather than to =E2=80=98(/ N 1)=E2=80=99. +The new behavior is compatible with Common Lisp and with XEmacs. +This change does not affect Lisp code intended to be portable to +Emacs 24.2 and earlier, which did not support unary =E2=80=98/=E2=80=99. + =0C * Lisp Changes in Emacs 25.1 =20 diff --git a/lisp/color.el b/lisp/color.el index d572222..97656ca 100644 --- a/lisp/color.el +++ b/lisp/color.el @@ -93,7 +93,7 @@ color-hue-to-rgb "Compute hue from V1 and V2 H. Used internally by `color-hsl-to-rgb'." (cond - ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) + ((< h (/ 6.0)) (+ v1 (* (- v2 v1) h 6.0))) ((< h 0.5) v2) ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) (t v1))) @@ -110,9 +110,9 @@ color-hsl-to-rgb (- (+ L S) (* L S)))) (m1 (- (* 2.0 L) m2))) (list - (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1)) + (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1)) (color-hue-to-rgb m1 m2 H) - (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1)))))) + (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1)))))) =20 (defun color-complement-hex (color) "Return the color that is the complement of COLOR, in hexadecimal form= at." @@ -199,13 +199,13 @@ color-xyz-to-srgb (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) (list (if (<=3D r 0.0031308) (* 12.92 r) - (- (* 1.055 (expt r (/ 1 2.4))) 0.055)) + (- (* 1.055 (expt r (/ 2.4))) 0.055)) (if (<=3D g 0.0031308) (* 12.92 g) - (- (* 1.055 (expt g (/ 1 2.4))) 0.055)) + (- (* 1.055 (expt g (/ 2.4))) 0.055)) (if (<=3D b 0.0031308) (* 12.92 b) - (- (* 1.055 (expt b (/ 1 2.4))) 0.055))))) + (- (* 1.055 (expt b (/ 2.4))) 0.055))))) =20 (defconst color-d65-xyz '(0.950455 1.0 1.088753) "D65 white point in CIE XYZ.") @@ -222,13 +222,13 @@ color-xyz-to-lab (yr (/ Y Yr)) (zr (/ Z Zr)) (fx (if (> xr color-cie-=CE=B5) - (expt xr (/ 1 3.0)) + (expt xr (/ 3.0)) (/ (+ (* color-cie-=CE=BA xr) 16) 116.0))) (fy (if (> yr color-cie-=CE=B5) - (expt yr (/ 1 3.0)) + (expt yr (/ 3.0)) (/ (+ (* color-cie-=CE=BA yr) 16) 116.0))) (fz (if (> zr color-cie-=CE=B5) - (expt zr (/ 1 3.0)) + (expt zr (/ 3.0)) (/ (+ (* color-cie-=CE=BA zr) 16) 116.0)))) (list (- (* 116 fy) 16) ; L diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 6f7ba33..d138eff 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3617,8 +3617,8 @@ byte-compile-minus =20 (defun byte-compile-quo (form) (let ((len (length form))) - (cond ((<=3D len 2) - (byte-compile-subr-wrong-args form "2 or more")) + (cond ((< len 2) + (byte-compile-subr-wrong-args form "1 or more")) ((=3D len 3) (byte-compile-two-args form)) (t diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index dddfca7..afa021d 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -497,7 +497,7 @@ cl-float-limits (setq cl-least-positive-normalized-float y cl-least-negative-normalized-float (- y)) ;; Divide down until value underflows to zero. - (setq x (/ 1 z) y x) + (setq x (/ z) y x) (while (condition-case _ (> (/ x 2) 0) (arith-error nil)) (setq x (/ x 2))) (setq cl-least-positive-float x diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el index 482f829..f8d358c 100644 --- a/lisp/net/shr-color.el +++ b/lisp/net/shr-color.el @@ -211,7 +211,7 @@ shr-color-hue-to-rgb "Convert X Y H to RGB value." (when (< h 0) (incf h)) (when (> h 1) (decf h)) - (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6))) + (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6))) ((< h 0.5) y) ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6))) (t x))) @@ -223,9 +223,9 @@ shr-color-hsl-to-rgb-fractions (setq m2 (* l (+ s 1))) (setq m2 (- (+ l s) (* l s)))) (setq m1 (- (* l 2) m2)) - (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0))) + (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0))) (shr-color-hue-to-rgb m1 m2 h) - (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0)))))) + (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0)))))) =20 (defun shr-color->hexadecimal (color) "Convert any color format to hexadecimal representation. diff --git a/src/data.c b/src/data.c index b85d8a7..33fe285 100644 --- a/src/data.c +++ b/src/data.c @@ -2603,6 +2603,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, L= isp_Object *args) accum =3D 0; break; case Amult: + case Adiv: accum =3D 1; break; case Alogand: @@ -2658,7 +2659,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, L= isp_Object *args) accum *=3D next; break; case Adiv: - if (!argnum) + if (! (argnum || nargs =3D=3D 1)) accum =3D next; else { @@ -2727,7 +2728,7 @@ float_arith_driver (double accum, ptrdiff_t argnum,= enum arithop code, accum *=3D next; break; case Adiv: - if (!argnum) + if (! (argnum || nargs =3D=3D 1)) accum =3D next; else { @@ -2782,9 +2783,11 @@ usage: (* &rest NUMBERS-OR-MARKERS) */) } =20 DEFUN ("/", Fquo, Squo, 1, MANY, 0, - doc: /* Return first argument divided by all the remaining argume= nts. + doc: /* Divide number by divisors and return the result. +With two or more arguments, return first argument divided by the rest. +With one argument, return 1 divided by the argument. The arguments must be numbers or markers. -usage: (/ DIVIDEND &rest DIVISORS) */) +usage: (/ NUMBER &rest DIVISORS) */) (ptrdiff_t nargs, Lisp_Object *args) { ptrdiff_t argnum; --=20 2.1.0 --------------080800050905010008050404-- From unknown Thu Aug 21 12:10:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21690: (/ N) should return the reciprocal of N Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Oct 2015 19:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21690 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Paul Eggert Cc: 21690@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 21690-submit@debbugs.gnu.org id=B21690.1444938876362 (code B ref 21690); Thu, 15 Oct 2015 19:55:02 +0000 Received: (at 21690) by debbugs.gnu.org; 15 Oct 2015 19:54:36 +0000 Received: from localhost ([127.0.0.1]:52634 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmobj-00005l-LG for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:54:36 -0400 Received: from mtaout24.012.net.il ([80.179.55.180]:44876) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmobg-00005a-Q0 for 21690@debbugs.gnu.org; Thu, 15 Oct 2015 15:54:33 -0400 Received: from conversion-daemon.mtaout24.012.net.il by mtaout24.012.net.il (HyperSendmail v2007.08) id <0NWA00P001974M00@mtaout24.012.net.il> for 21690@debbugs.gnu.org; Thu, 15 Oct 2015 22:47:43 +0300 (IDT) Received: from HOME-C4E4A596F7 ([84.94.185.246]) by mtaout24.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NWA00MNM1NJE230@mtaout24.012.net.il>; Thu, 15 Oct 2015 22:47:43 +0300 (IDT) Date: Thu, 15 Oct 2015 22:54:27 +0300 From: Eli Zaretskii In-reply-to: <561FFA47.6020401@cs.ucla.edu> X-012-Sender: halo1@inter.net.il Message-id: <8361279abw.fsf@gnu.org> References: <561FFA47.6020401@cs.ucla.edu> X-Spam-Score: 1.0 (+) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Paul Eggert > Date: Thu, 15 Oct 2015 12:11:03 -0700 > > We're in feature-freeze now No, we aren't. From unknown Thu Aug 21 12:10:32 2025 X-Loop: help-debbugs@gnu.org Subject: bug#21690: (/ N) should return the reciprocal of N Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 15 Oct 2015 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21690 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch To: Eli Zaretskii Cc: 21690@debbugs.gnu.org Received: via spool by 21690-submit@debbugs.gnu.org id=B21690.14449403412660 (code B ref 21690); Thu, 15 Oct 2015 20:20:02 +0000 Received: (at 21690) by debbugs.gnu.org; 15 Oct 2015 20:19:01 +0000 Received: from localhost ([127.0.0.1]:52654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZmozN-0000gm-5h for submit@debbugs.gnu.org; Thu, 15 Oct 2015 16:19:01 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36985) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZmozK-0000gd-SR for 21690@debbugs.gnu.org; Thu, 15 Oct 2015 16:18:59 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 349DB160707; Thu, 15 Oct 2015 13:18:58 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id z2BKrOtkzZXx; Thu, 15 Oct 2015 13:18:57 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7B56D160CB6; Thu, 15 Oct 2015 13:18:57 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id q7K2TBa6XrYP; Thu, 15 Oct 2015 13:18:57 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 6251E160707; Thu, 15 Oct 2015 13:18:57 -0700 (PDT) References: <561FFA47.6020401@cs.ucla.edu> <8361279abw.fsf@gnu.org> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <56200A31.8070100@cs.ucla.edu> Date: Thu, 15 Oct 2015 13:18:57 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <8361279abw.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.0 (/) On 10/15/2015 12:54 PM, Eli Zaretskii wrote: >> From: Paul Eggert >> Date: Thu, 15 Oct 2015 12:11:03 -0700 >> >> We're in feature-freeze now > No, we aren't. Ah, sorry, I misremembered Stefan's message of a couple of weeks ago. In that case there's no freeze-based objection to installing this change now. From unknown Thu Aug 21 12:10:32 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Paul Eggert Subject: bug#21690: closed (Re: bug#21690: (/ N) should return the reciprocal of N) Message-ID: References: <5626E935.5000302@cs.ucla.edu> <561FFA47.6020401@cs.ucla.edu> X-Gnu-PR-Message: they-closed 21690 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: patch Reply-To: 21690@debbugs.gnu.org Date: Wed, 21 Oct 2015 01:25:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1445390702-23136-1" This is a multi-part message in MIME format... ------------=_1445390702-23136-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #21690: (/ N) should return the reciprocal of N which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 21690@debbugs.gnu.org. --=20 21690: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D21690 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1445390702-23136-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 21690-done) by debbugs.gnu.org; 21 Oct 2015 01:24:10 +0000 Received: from localhost ([127.0.0.1]:58557 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zoi8P-000605-Ki for submit@debbugs.gnu.org; Tue, 20 Oct 2015 21:24:09 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:39303) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zoi8N-0005zv-IG for 21690-done@debbugs.gnu.org; Tue, 20 Oct 2015 21:24:08 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B46B91608D3 for <21690-done@debbugs.gnu.org>; Tue, 20 Oct 2015 18:24:06 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gEEl8hJeuKp7 for <21690-done@debbugs.gnu.org>; Tue, 20 Oct 2015 18:24:06 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1BC59160D3D for <21690-done@debbugs.gnu.org>; Tue, 20 Oct 2015 18:24:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XUI5I0CIsOpF for <21690-done@debbugs.gnu.org>; Tue, 20 Oct 2015 18:24:06 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id F2E1D1608CE for <21690-done@debbugs.gnu.org>; Tue, 20 Oct 2015 18:24:05 -0700 (PDT) Subject: Re: bug#21690: (/ N) should return the reciprocal of N To: 21690-done@debbugs.gnu.org References: <561FFA47.6020401@cs.ucla.edu> <8361279abw.fsf@gnu.org> <56200A31.8070100@cs.ucla.edu> From: Paul Eggert Organization: UCLA Computer Science Department Message-ID: <5626E935.5000302@cs.ucla.edu> Date: Tue, 20 Oct 2015 18:24:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <56200A31.8070100@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21690-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) No further comment, so I installed the patch as master commit e9af822ac3ddf9644aa4a68e56b0580e133449b2 and am marking this as done. ------------=_1445390702-23136-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 15 Oct 2015 19:11:22 +0000 Received: from localhost ([127.0.0.1]:52619 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmnvt-0007UF-Jh for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:55273) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zmnvq-0007U6-Ou for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmnvo-0003mX-V4 for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:18 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:40804) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvo-0003mK-Ry for submit@debbugs.gnu.org; Thu, 15 Oct 2015 15:11:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37034) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvm-0004VU-Bh for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zmnvi-0003kR-7H for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:14 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:33921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zmnvh-0003kK-VB for bug-gnu-emacs@gnu.org; Thu, 15 Oct 2015 15:11:10 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B5FA7160CB6 for ; Thu, 15 Oct 2015 12:11:08 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id V1RkKB99VL9X for ; Thu, 15 Oct 2015 12:11:07 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id EA793160D3D for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id BLA-w24GGdby for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) Received: from Penguin.CS.UCLA.EDU (Penguin.CS.UCLA.EDU [131.179.64.200]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id AD4C1160CB6 for ; Thu, 15 Oct 2015 12:11:06 -0700 (PDT) To: GNU Emacs bug reports From: Paul Eggert Subject: (/ N) should return the reciprocal of N Organization: UCLA Computer Science Department Message-ID: <561FFA47.6020401@cs.ucla.edu> Date: Thu, 15 Oct 2015 12:11:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080800050905010008050404" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) This is a multi-part message in MIME format. --------------080800050905010008050404 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Tags: patch The attached proposed patch is a followup to the recent discussion on emacs-devel. We're in feature-freeze now, so it's not a good time to apply it. Although I'm sympathetic to Stefan's point that the Common Lisp behavior is less logical, it is more useful in practice (as can be seen from some uses in the proposed patch) and there is a benefit to being compatible with CL. --------------080800050905010008050404 Content-Type: text/x-patch; name="0001-N-now-returns-the-reciprocal-of-N.patch" Content-Disposition: attachment; filename="0001-N-now-returns-the-reciprocal-of-N.patch" Content-Transfer-Encoding: quoted-printable >From b512e3a7a814eba4f09c11c3aad6d96ea6d0ae7c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 15 Oct 2015 12:05:35 -0700 Subject: [PATCH] (/ N) now returns the reciprocal of N MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This is more compatible with Common Lisp and with XEmacs. See: http://lists.gnu.org/archive/html/emacs-devel/2015-10/msg01053.html * lisp/color.el (color-hue-to-rgb, color-hsl-to-rgb) (color-xyz-to-srgb, color-xyz-to-lab): * lisp/emacs-lisp/cl-extra.el (cl-float-limits): * lisp/net/shr-color.el (shr-color-hue-to-rgb) (shr-color-hsl-to-rgb-fractions): Exploit the change to simplify the code a bit. * lisp/emacs-lisp/bytecomp.el (byte-compile-quo): Don=E2=80=99t complain about single-argument calls to =E2=80=98/=E2=80=99= . * src/data.c (arith_driver, float_arith_driver): Implement the change. --- doc/lispref/numbers.texi | 17 +++++++++++++---- etc/NEWS | 6 ++++++ lisp/color.el | 18 +++++++++--------- lisp/emacs-lisp/bytecomp.el | 4 ++-- lisp/emacs-lisp/cl-extra.el | 2 +- lisp/net/shr-color.el | 6 +++--- src/data.c | 11 +++++++---- 7 files changed, 41 insertions(+), 23 deletions(-) diff --git a/doc/lispref/numbers.texi b/doc/lispref/numbers.texi index 3c70d2f..54c8d3e 100644 --- a/doc/lispref/numbers.texi +++ b/doc/lispref/numbers.texi @@ -642,10 +642,11 @@ Arithmetic Operations @end example @end defun =20 -@defun / dividend divisor &rest divisors -This function divides @var{dividend} by @var{divisor} and returns the -quotient. If there are additional arguments @var{divisors}, then it -divides @var{dividend} by each divisor in turn. Each argument may be a +@defun / number &rest divisors +With one or more @var{divisors}, this function divides @var{number} +by each divisor in @var{divisors} in turn, and returns the quotient. +With no @var{divisors}, this function returns 1/@var{number}, i.e., +the multiplicative inverse of @var{number}. Each argument may be a number or a marker. =20 If all the arguments are integers, the result is an integer, obtained @@ -673,6 +674,14 @@ Arithmetic Operations @result{} 2.5 @end group @group +(/ 4.0) + @result{} 0.25 +@end group +@group +(/ 4) + @result{} 0 +@end group +@group (/ 25 3 2) @result{} 4 @end group diff --git a/etc/NEWS b/etc/NEWS index dbe0de3..8170c4a 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1007,6 +1007,12 @@ dynamically. dynamically. Any third-party code that changes these templates should be updated accordingly. =20 ++++ +** =E2=80=98(/ N)=E2=80=99 is now equivalent to =E2=80=98(/ 1 N)=E2=80=99= rather than to =E2=80=98(/ N 1)=E2=80=99. +The new behavior is compatible with Common Lisp and with XEmacs. +This change does not affect Lisp code intended to be portable to +Emacs 24.2 and earlier, which did not support unary =E2=80=98/=E2=80=99. + =0C * Lisp Changes in Emacs 25.1 =20 diff --git a/lisp/color.el b/lisp/color.el index d572222..97656ca 100644 --- a/lisp/color.el +++ b/lisp/color.el @@ -93,7 +93,7 @@ color-hue-to-rgb "Compute hue from V1 and V2 H. Used internally by `color-hsl-to-rgb'." (cond - ((< h (/ 1.0 6)) (+ v1 (* (- v2 v1) h 6.0))) + ((< h (/ 6.0)) (+ v1 (* (- v2 v1) h 6.0))) ((< h 0.5) v2) ((< h (/ 2.0 3)) (+ v1 (* (- v2 v1) (- (/ 2.0 3) h) 6.0))) (t v1))) @@ -110,9 +110,9 @@ color-hsl-to-rgb (- (+ L S) (* L S)))) (m1 (- (* 2.0 L) m2))) (list - (color-hue-to-rgb m1 m2 (mod (+ H (/ 1.0 3)) 1)) + (color-hue-to-rgb m1 m2 (mod (+ H (/ 3.0)) 1)) (color-hue-to-rgb m1 m2 H) - (color-hue-to-rgb m1 m2 (mod (- H (/ 1.0 3)) 1)))))) + (color-hue-to-rgb m1 m2 (mod (- H (/ 3.0)) 1)))))) =20 (defun color-complement-hex (color) "Return the color that is the complement of COLOR, in hexadecimal form= at." @@ -199,13 +199,13 @@ color-xyz-to-srgb (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z)))) (list (if (<=3D r 0.0031308) (* 12.92 r) - (- (* 1.055 (expt r (/ 1 2.4))) 0.055)) + (- (* 1.055 (expt r (/ 2.4))) 0.055)) (if (<=3D g 0.0031308) (* 12.92 g) - (- (* 1.055 (expt g (/ 1 2.4))) 0.055)) + (- (* 1.055 (expt g (/ 2.4))) 0.055)) (if (<=3D b 0.0031308) (* 12.92 b) - (- (* 1.055 (expt b (/ 1 2.4))) 0.055))))) + (- (* 1.055 (expt b (/ 2.4))) 0.055))))) =20 (defconst color-d65-xyz '(0.950455 1.0 1.088753) "D65 white point in CIE XYZ.") @@ -222,13 +222,13 @@ color-xyz-to-lab (yr (/ Y Yr)) (zr (/ Z Zr)) (fx (if (> xr color-cie-=CE=B5) - (expt xr (/ 1 3.0)) + (expt xr (/ 3.0)) (/ (+ (* color-cie-=CE=BA xr) 16) 116.0))) (fy (if (> yr color-cie-=CE=B5) - (expt yr (/ 1 3.0)) + (expt yr (/ 3.0)) (/ (+ (* color-cie-=CE=BA yr) 16) 116.0))) (fz (if (> zr color-cie-=CE=B5) - (expt zr (/ 1 3.0)) + (expt zr (/ 3.0)) (/ (+ (* color-cie-=CE=BA zr) 16) 116.0)))) (list (- (* 116 fy) 16) ; L diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 6f7ba33..d138eff 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -3617,8 +3617,8 @@ byte-compile-minus =20 (defun byte-compile-quo (form) (let ((len (length form))) - (cond ((<=3D len 2) - (byte-compile-subr-wrong-args form "2 or more")) + (cond ((< len 2) + (byte-compile-subr-wrong-args form "1 or more")) ((=3D len 3) (byte-compile-two-args form)) (t diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el index dddfca7..afa021d 100644 --- a/lisp/emacs-lisp/cl-extra.el +++ b/lisp/emacs-lisp/cl-extra.el @@ -497,7 +497,7 @@ cl-float-limits (setq cl-least-positive-normalized-float y cl-least-negative-normalized-float (- y)) ;; Divide down until value underflows to zero. - (setq x (/ 1 z) y x) + (setq x (/ z) y x) (while (condition-case _ (> (/ x 2) 0) (arith-error nil)) (setq x (/ x 2))) (setq cl-least-positive-float x diff --git a/lisp/net/shr-color.el b/lisp/net/shr-color.el index 482f829..f8d358c 100644 --- a/lisp/net/shr-color.el +++ b/lisp/net/shr-color.el @@ -211,7 +211,7 @@ shr-color-hue-to-rgb "Convert X Y H to RGB value." (when (< h 0) (incf h)) (when (> h 1) (decf h)) - (cond ((< h (/ 1 6.0)) (+ x (* (- y x) h 6))) + (cond ((< h (/ 6.0)) (+ x (* (- y x) h 6))) ((< h 0.5) y) ((< h (/ 2.0 3.0)) (+ x (* (- y x) (- (/ 2.0 3.0) h) 6))) (t x))) @@ -223,9 +223,9 @@ shr-color-hsl-to-rgb-fractions (setq m2 (* l (+ s 1))) (setq m2 (- (+ l s) (* l s)))) (setq m1 (- (* l 2) m2)) - (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 1 3.0))) + (list (shr-color-hue-to-rgb m1 m2 (+ h (/ 3.0))) (shr-color-hue-to-rgb m1 m2 h) - (shr-color-hue-to-rgb m1 m2 (- h (/ 1 3.0)))))) + (shr-color-hue-to-rgb m1 m2 (- h (/ 3.0)))))) =20 (defun shr-color->hexadecimal (color) "Convert any color format to hexadecimal representation. diff --git a/src/data.c b/src/data.c index b85d8a7..33fe285 100644 --- a/src/data.c +++ b/src/data.c @@ -2603,6 +2603,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, L= isp_Object *args) accum =3D 0; break; case Amult: + case Adiv: accum =3D 1; break; case Alogand: @@ -2658,7 +2659,7 @@ arith_driver (enum arithop code, ptrdiff_t nargs, L= isp_Object *args) accum *=3D next; break; case Adiv: - if (!argnum) + if (! (argnum || nargs =3D=3D 1)) accum =3D next; else { @@ -2727,7 +2728,7 @@ float_arith_driver (double accum, ptrdiff_t argnum,= enum arithop code, accum *=3D next; break; case Adiv: - if (!argnum) + if (! (argnum || nargs =3D=3D 1)) accum =3D next; else { @@ -2782,9 +2783,11 @@ usage: (* &rest NUMBERS-OR-MARKERS) */) } =20 DEFUN ("/", Fquo, Squo, 1, MANY, 0, - doc: /* Return first argument divided by all the remaining argume= nts. + doc: /* Divide number by divisors and return the result. +With two or more arguments, return first argument divided by the rest. +With one argument, return 1 divided by the argument. The arguments must be numbers or markers. -usage: (/ DIVIDEND &rest DIVISORS) */) +usage: (/ NUMBER &rest DIVISORS) */) (ptrdiff_t nargs, Lisp_Object *args) { ptrdiff_t argnum; --=20 2.1.0 --------------080800050905010008050404-- ------------=_1445390702-23136-1--