Subject: Re: bug#31715: cl-incf and cl-decf error out when passed a nil-valued variable as 'offset'

From: Michael Heerdegen <[email-masked]>
Date: Tue, 05 Jun 2018 01:43:21 +0200

Noam Postavsky <[email-masked]> writes:

> X is an optional macro parameter, so the "optionalness" applies at
> compile time.

Are you sure we always treat optional macro parameters like this?

> I think that would approximately double the cost of cl-incf in the
> simple case [...]

We could drop the optimization in case an X expression is specified,
resulting in one additional `or' call:

(defmacro cl-incf (place &optional x)
  (if (and (symbolp place) (not x))
      (list 'setq place (list '1+ place))
    (list 'cl-callf '+ place (or x 1))))

Would that be significantly slower than the current definition?

Michael.