all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs-Devel <emacs-devel@gnu.org>
Subject: Re: changing function signatures and no library version # => must use too-general test
Date: Tue, 25 Apr 2006 14:57:23 -0400	[thread overview]
Message-ID: <jwvpsj5cx0a.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <MEEKKIABFKKDFJMPIOEBAEOKDAAA.drew.adams@oracle.com> (Drew Adams's message of "Tue, 25 Apr 2006 10:30:30 -0700")

> There is no good way to test for the function with the right signature,
> AFAIK. In Emacs 22 I could use `subr-arity' to test the number of args,
> which would work in this case but not in cases where the number was the same
> but the parameter types were different or their order changed - and, anyway,
> that would require testing whether `subr-arity' is defined, and, if not, it
> would require a different test (for Emacs other than 22).

Testing with subr-arity won't work because it's not a subroutine, and even
if it works it's difficult to use and inconvenient.  A better check is:

   (condition-case nil
       (help-insert-xref-button arg1 arg2 arg3)
     (wrong-number-of-arguments
      (help-insert-xref-button arg6 arg7))

and interestingly, this approach can also be used when the number of args
hasn't changed, as long as you can arrange for the first call to fail
immediately (e.g. because you use some new type of argument that wasn't
supported before).

Of course, this is not 100% errorproof since the error you catch may
actually come from some other piece of code within help-insert-xref-button.
In many cases this is not a problem because you can be reasonably sure that
having the same error signalled some other way is extremely unlikely
(e.g. this is the case for wrong-number-of-arguments).


        Stefan

  reply	other threads:[~2006-04-25 18:57 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-25 17:30 changing function signatures and no library version # => must use too-general test Drew Adams
2006-04-25 18:57 ` Stefan Monnier [this message]
2006-04-25 19:39   ` Drew Adams
2006-04-25 20:35     ` Stefan Monnier
2006-04-25 21:48       ` Drew Adams
2006-04-26  2:41         ` Miles Bader
2006-04-26  4:55         ` Stefan Monnier
2006-04-26  6:21           ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvpsj5cx0a.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.