emacs-devel
[Top][All Lists]
Advanced

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

Re: changing function signatures and no library version # => must use to


From: Stefan Monnier
Subject: Re: changing function signatures and no library version # => must use too-general test
Date: Tue, 25 Apr 2006 14:57:23 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> 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 via email to

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