bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

wish cl.el supported (cons CAR-TYPE CDR-TYPE) type specifiers


From: Kalle Olavi Niemitalo
Subject: wish cl.el supported (cons CAR-TYPE CDR-TYPE) type specifiers
Date: 14 Apr 2001 14:05:00 +0300

In GNU Emacs 20.7.2 (i386-debian-linux-gnu, X toolkit)
 of Fri Apr 13 2001 on PC486
configured using `configure  i386-debian-linux-gnu --prefix=/usr 
--sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib 
--infodir=/usr/share/info --with-pop=yes --with-x=yes --with-x-toolkit=yes'

The type-checking macros and functions of cl.el currently don't
support the Common Lisp (cons CAR-TYPE CDR-TYPE) type specifier
syntax:

ELISP> (typep '(1 . 2) '(cons integer integer))
*** Eval error ***  error: "Bad type spec: (cons integer integer)"

Please add such support in the next version.  It is particularly
useful in `typecase'.

I can define an equivalent `kon-cons' type myself, but I'd prefer
using the standard name.  Also, `(typep x '(kon-cons integer *))'
binds one extra variable even in byte-compiled code and I'd like
to get rid of that.

(deftype kon-cons (&optional (car-type '*) (cdr-type '*))
  (let ((value-sym (gensym)))
    `(satisfies (lambda (,value-sym)
                  (and (consp ,value-sym)
                       ;; Try to avoid generating t arguments,
                       ;; because those prevent the previous
                       ;; value from being used directly.
                       ,@(unless (eq car-type '*)
                           `((typep (car ,value-sym) ',car-type)))
                       ,@(unless (eq cdr-type '*)
                           `((typep (cdr ,value-sym) ',cdr-type))))))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]