unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* 23.0.50; assert arguments warning
@ 2008-01-15 18:57 Lennart Borgman (gmail)
  2008-01-16  8:31 ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-01-15 18:57 UTC (permalink / raw)
  To: emacs-pretest-bug

Start from

   emacs -Q

and byte compile a file that contains

   (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
     field(s)


In GNU Emacs 23.0.50.1 (i386-mingw-nt5.1.2600)
  of 2008-01-13
Windowing system distributor `Microsoft Corp.', version 5.1.2600
configured using `configure --with-gcc (3.4) --cflags -Ic:/g/include'

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 23.0.50; assert arguments warning
  2008-01-15 18:57 23.0.50; assert arguments warning Lennart Borgman (gmail)
@ 2008-01-16  8:31 ` Richard Stallman
  2008-01-16 15:10   ` Lennart Borgman (gmail)
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Stallman @ 2008-01-16  8:31 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-pretest-bug

       (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
	 field(s)

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 23.0.50; assert arguments warning
  2008-01-16  8:31 ` Richard Stallman
@ 2008-01-16 15:10   ` Lennart Borgman (gmail)
  2008-01-18  4:37     ` Richard Stallman
  0 siblings, 1 reply; 4+ messages in thread
From: Lennart Borgman (gmail) @ 2008-01-16 15:10 UTC (permalink / raw)
  To: rms; +Cc: emacs-pretest-bug

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
> 	 field(s)
> 
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 23.0.50; assert arguments warning
  2008-01-16 15:10   ` Lennart Borgman (gmail)
@ 2008-01-18  4:37     ` Richard Stallman
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2008-01-18  4:37 UTC (permalink / raw)
  To: Lennart Borgman (gmail); +Cc: emacs-pretest-bug

       (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.

I think that last sentence is misleading

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

That addition is clear.

Would someone please fix this?


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

Would someone please DTRT?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-01-18  4:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-15 18:57 23.0.50; assert arguments warning Lennart Borgman (gmail)
2008-01-16  8:31 ` Richard Stallman
2008-01-16 15:10   ` Lennart Borgman (gmail)
2008-01-18  4:37     ` Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).