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

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

bug#31715: cl-incf and cl-decf error out when passed a nil-valued variab


From: Michael Heerdegen
Subject: bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset'
Date: Wed, 06 Jun 2018 02:32:18 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Noam Postavsky <npostavs@gmail.com> writes:

> Oh, huh, I didn't think to check that case.  Maybe we should just change
> cl-incf to disintguish between nil and unspecified then.
>
> (defmacro cl-incf (place &rest args)
>   "Increment PLACE by X (1 by default).
> PLACE may be a symbol, or any generalized variable allowed by `setf'.
> The return value is the incremented value of PLACE.
>
> \(fn PLACE &optional X)"
>   (declare (debug (place &optional form)))
>   (let* ((got-x (= (length args) 1))
>          (x (car args)))
>     (if (symbolp place)
>         (list 'setq place (if got-x (list '+ place x) (list '1+ place)))
>       (list 'cl-callf '+ place (if got-x x 1)))))

That's quite hackish, just to make (cl-incf x nil) error, which is a
backward incompatible change with no real gain.  Wouldn't we even lose
the byte compiler barfing for something like (incf x 1 2)?


Michael.





reply via email to

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