GNU bug report logs - #77725
31.0.50; Add support for types accepted by `cl-typep' to cl-generic?

Previous Next

Package: emacs;

Reported by: David Ponce <da_vid <at> orange.fr>

Date: Fri, 11 Apr 2025 07:16:01 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: David Ponce <da_vid <at> orange.fr>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 77725 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?
Date: Sat, 17 May 2025 16:41:24 +0200
[Message part 1 (text/plain, inline)]
[...]
>> That's fine with me.  I asked because it seemed to me that it wasn't
>> recommended to load cl-macs but rather cl-lib.
> 
> Yes, but that worked OK because in order to *use* those types you needed
> to use `cl-deftype` or `cl-typep`, both of which are autoloaded from
> `cl-macs.el`.

You are right, I forgot that, sorry.

>>> Some of those types are virtually never used, so maybe we'll want to
>>> move some but not all?
>> To be honest, I don't know if/when these types are used.
> 
> `grep` can provide some answers to that question.  🙂

Sure ;-)



Please find attached a proposal to improve error handling in
`cl-types-of'.  Ultimately, I think you were right and it is better to
simply report derived type errors to the caller and abort processing,
but while also preventing their recurrence as much as possible :-)

So my proposal is to still handle any error on a derived type, in
order to disable the type as is currently done by removing it from the
list of types; but, instead of warn, raise a new `cl-type-error'
mentioning the type in error and the underlying error.  Here are some
simple examples for you to observe the result.

(cl-deftype T1 ()
  '(satisfies plusp))

(cl-types-of -0.5)
=> (real float number number-or-marker atom t)

(cl-types-of 12)
=> (T1 real base-char character fixnum natnum integer number integer-or-marker number-or-marker atom t)

(cl-types-of "12")
=> Error on derived type: T1, (wrong-type-argument number-or-marker-p "12")

(cl-deftype T2 ()
  `(satisfies ,(lambda (o) (memq 'T1 (cl-types-of o)))))

(cl-types-of "12")
=> Error on derived type: T2, (excessive-lisp-nesting 1601)

Does it make sense?

Thanks!
David
[cl-extra.patch (text/x-patch, attachment)]

This bug report was last modified 10 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.