From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Anders Lindgren Newsgroups: gmane.emacs.bugs Subject: bug#21701: Fwd: cl-typecase broken (was 25.0.50; ert explainer for equal can't handle negative numbers) Date: Fri, 4 Dec 2015 16:41:46 +0100 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a114405c655e4fd0526145896 X-Trace: ger.gmane.org 1449243762 14037 80.91.229.3 (4 Dec 2015 15:42:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 4 Dec 2015 15:42:42 +0000 (UTC) Cc: 21701-done@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 04 16:42:33 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1a4sUu-0008QS-9Y for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Dec 2015 16:42:13 +0100 Original-Received: from localhost ([::1]:41648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4sUs-0004c0-Ff for geb-bug-gnu-emacs@m.gmane.org; Fri, 04 Dec 2015 10:42:10 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4sUp-0004Zn-CV for bug-gnu-emacs@gnu.org; Fri, 04 Dec 2015 10:42:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a4sUk-0007kk-H5 for bug-gnu-emacs@gnu.org; Fri, 04 Dec 2015 10:42:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:49444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a4sUk-0007kd-DP for bug-gnu-emacs@gnu.org; Fri, 04 Dec 2015 10:42:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1a4sUk-0008II-9V for bug-gnu-emacs@gnu.org; Fri, 04 Dec 2015 10:42:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Anders Lindgren Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 04 Dec 2015 15:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21701 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21701-done@debbugs.gnu.org id=D21701.144924371031863 (code D ref 21701); Fri, 04 Dec 2015 15:42:02 +0000 Original-Received: (at 21701-done) by debbugs.gnu.org; 4 Dec 2015 15:41:50 +0000 Original-Received: from localhost ([127.0.0.1]:39152 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a4sUX-0008Hq-La for submit@debbugs.gnu.org; Fri, 04 Dec 2015 10:41:50 -0500 Original-Received: from mail-vk0-f43.google.com ([209.85.213.43]:33611) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1a4sUV-0008Hi-8z for 21701-done@debbugs.gnu.org; Fri, 04 Dec 2015 10:41:47 -0500 Original-Received: by vkca188 with SMTP id a188so68195886vkc.0 for <21701-done@debbugs.gnu.org>; Fri, 04 Dec 2015 07:41:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=QxU+w/fmROtLhgn9wywDf5leLli4vQCL7RXDwtg0iu4=; b=kqqjnjFliayVY2DRVDz8Yy7Ckv/kfjI5g+Pvz2Hkl4e9sXqk3bZHXtMhactcshcMOl BxRv5gMfIjhUlJTGg+iFU1Ao2hDYrDgArJ1/qMbPSxNd9yO+bCjGZsDSmkqY2xC6QleZ M+CqjPbUfNAsY4Jn295qL61J2UgTz4O+ZxNArGrCVA1ri+Mch7d5qaG+7QZaXcD+bedj lYjYzxX8K4PP+/ARkjKqWpPDgtOC3QR/H3eh1XV4mQpBpRFv6OcmxD3tz/CZog70jEgG 2EOy4IaqS5MmYF+6wNjbm0vSSpAaB9GoEiKWb2KjvB3uv2Ut9gDPpnNIOE2PNvqyIda3 OlXA== X-Received: by 10.31.58.74 with SMTP id h71mr10589468vka.149.1449243706776; Fri, 04 Dec 2015 07:41:46 -0800 (PST) Original-Received: by 10.31.210.133 with HTTP; Fri, 4 Dec 2015 07:41:46 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:109593 Archived-At: --001a114405c655e4fd0526145896 Content-Type: text/plain; charset=UTF-8 Hi, This should solve the immediate problem with negative numbers. However, I gave this some though and realised that there is still a problem with large numbers. For example: (cl-typecase (+ (max-char) 1) (character "A character") (fixnum "A fixnum") (t "Something else")) Returns "A character". However, "(format "%c" (+ (max-char) 1))" raises the error "(wrong-type-argument characterp 4194304)". The question is if `cl-typecase', `format', and `characterp' should have the same definition on what a character is. If not, then ERT must be modified to handle this, e.g. by using `base-char' rather than `character'. Personally, I would perfer if `character' would mean the same thing in all contexts. I would suggest that we restore the old meaning of `character', drop `base-char', and add a new type class, say `key-event', that could include things like ?\M-\C-x. -- Anders On Fri, Dec 4, 2015 at 2:30 PM, Stefan Monnier wrote: > > I just realised that the underlying problem is a change to `cl-typecase'. > > It treats -50 as a character. > > > > (cl-typecase -50 > > (character "A character") > > (fixnum "A fixnum") > > (t "Something else")) > > > > Emacs 25 returns "A character" and emacs 24 "A fixnum". > > I installed the patch below which should fix this. > > > Stefan > > > diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el > index 09d2d3f..c8aad3a 100644 > --- a/lisp/emacs-lisp/cl-macs.el > +++ b/lisp/emacs-lisp/cl-macs.el > @@ -2885,7 +2885,7 @@ cl--macroexp-fboundp > (put 'real 'cl-deftype-satisfies #'numberp) > (put 'fixnum 'cl-deftype-satisfies #'integerp) > (put 'base-char 'cl-deftype-satisfies #'characterp) > -(put 'character 'cl-deftype-satisfies #'integerp) > +(put 'character 'cl-deftype-satisfies #'natnump) > > > ;;;###autoload > --001a114405c655e4fd0526145896 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi,

This should solve the immediate pro= blem with negative numbers.

However, I gave this s= ome though and realised that there is still a problem with large numbers. F= or example:

(cl-typecase (+ (max-char) 1)
=C2=A0 (character "A character")
=C2=A0 (fixnum = "A fixnum")
=C2=A0 (t "Something else"))

Returns "A character".

<= /div>
However, "(format "%c" (+ (max-char) 1))" rai= ses the error "(wrong-type-argument characterp 4194304)".

The question is if `cl-typecase', `format', and `= characterp' should have the same definition on what a character is. If = not, then ERT must be modified to handle this, e.g. by using `base-char'= ; rather than `character'.

Personally, I would= perfer if `character' would mean the same thing in all contexts. I wou= ld suggest that we restore the old meaning of `character', drop `base-c= har', and add a new type class, say `key-event', that could include= things like ?\M-\C-x.

=C2=A0 =C2=A0 -- Anders

On Fri, D= ec 4, 2015 at 2:30 PM, Stefan Monnier <monnier@iro.umontreal.ca= > wrote:
> = I just realised that the underlying problem is a change to `cl-typecase'= ;.
> It treats -50 as a character.
>
> (cl-typecase -50
>=C2=A0 =C2=A0(character "A character")
>=C2=A0 =C2=A0(fixnum "A fixnum")
>=C2=A0 =C2=A0(t "Something else"))
>
> Emacs 25 returns "A character" and emacs 24 "A fixnum&q= uot;.

I installed the patch below which should fix this.


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan


diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 09d2d3f..c8aad3a 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2885,7 +2885,7 @@ cl--macroexp-fboundp
=C2=A0(put 'real 'cl-deftype-satisfies #'numberp)
=C2=A0(put 'fixnum 'cl-deftype-satisfies #'integerp)
=C2=A0(put 'base-char 'cl-deftype-satisfies #'characterp)
-(put 'character 'cl-deftype-satisfies #'integerp)
+(put 'character 'cl-deftype-satisfies #'natnump)


=C2=A0;;;###autoload

--001a114405c655e4fd0526145896--