[Top][All Lists]

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

Re: 23.0.50; assert arguments warning

From: Lennart Borgman (gmail)
Subject: Re: 23.0.50; assert arguments warning
Date: Wed, 16 Jan 2008 16:10:39 +0100
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071031 Thunderbird/ Mnenhy/

Richard Stallman wrote:
       (eval-when-compile (require 'cl))
       (let ((end 1)(pos 2))
         (assert (<= pos end) t "p=%s e=%s" pos end))

    This gives a warning

       my-file.el:32:42:Warning: `error' called with 4 args to fill 2 format

That error seems correct.  You gave t for SHOW-ARGS, so it put
`pos' and `end' into the `error' call automatically.  Then you
added `pos' and `end' yourself.  That makes 4 format args,
but just two %s to display them.

I wonder if SHOW-ARGS is not properly documented.  Did you misunderstand
its meaning?

I believe it is not wrong to say that the doc string is wrong. Or at least it is incomplete. Here is a proposal for a new doc string:

  (defmacro assert (form &optional show-args format-string &rest args)
  "Verify that FORM returns non-nil; signal an error if not.
If FORMAT-STRING is nil, a default message listing FORM itself is
used and in this case ARGS are ignored.  If SHOW-ARGS is non-nil
this message will include the values of the arguments of FORM.

If FORMAT-STRING is a string then this, the FORM arguments \(when
SHOW-ARGS is non-nil) and ARGS are passed to `error'.

ARGS are not evaluated unless the assertion fails."

BTW the doc string for `format' is incorrect because the name of the argument STRING has not been changed in src/editfns.c.

reply via email to

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