From: Anders Lindgren <andlind@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 21701-done@debbugs.gnu.org
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 [thread overview]
Message-ID: <CABr8ebZ+60ZPFTOg8EP+Mqn5A-zOSU-ww1oSodJhBsavosv1EA@mail.gmail.com> (raw)
In-Reply-To: <jwv1tb2pciw.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1846 bytes --]
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 <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
> > (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
>
[-- Attachment #2: Type: text/html, Size: 2758 bytes --]
next prev parent reply other threads:[~2015-12-04 15:41 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-18 8:56 bug#21701: 25.0.50; ert explainer for equal can't handle negative numbers (work in 24.5) Anders Lindgren
2015-12-04 9:41 ` bug#21701: cl-typecase broken (was 25.0.50; ert explainer for equal can't handle negative numbers) Anders Lindgren
[not found] ` <CABr8ebZdsbyLDjayLSXRDqhvyGSTngfdLcKruwavYHmG_MPpWA@mail.gmail.com>
2015-12-04 13:30 ` bug#21701: Fwd: " Stefan Monnier
2015-12-04 15:41 ` Anders Lindgren [this message]
2015-12-04 17:36 ` Stefan Monnier
2015-12-04 18:17 ` Stefan Monnier
2015-12-04 19:42 ` Anders Lindgren
2015-12-04 21:08 ` Drew Adams
2015-12-04 21:25 ` Stefan Monnier
2015-12-04 21:32 ` Drew Adams
2015-12-04 22:58 ` Glenn Morris
2015-12-05 15:08 ` Anders Lindgren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABr8ebZ+60ZPFTOg8EP+Mqn5A-zOSU-ww1oSodJhBsavosv1EA@mail.gmail.com \
--to=andlind@gmail.com \
--cc=21701-done@debbugs.gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).