unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: changing function signatures and no library version # => must use too-general test
Date: Tue, 25 Apr 2006 12:39:37 -0700	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICEEEBDFAA.drew.adams@oracle.com> (raw)
In-Reply-To: <jwvpsj5cx0a.fsf-monnier+emacs@gnu.org>

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

(As Davis Herrington pointed out off-list, I should have written "pre-Emacs
21" instead of "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))

Yes, I considered that.

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

Only if the different type in fact raises an error (as opposed to producing
incorrect results or leading to an error farther down the road).

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

Yes, I agree with everything you said. It doesn't change the general
problem, however. Rather than users needing to define their own function
that does what you wrote above (if case they want to do that in multiple
places, for instance), Emacs developers should just define a new, different
function themselves (not pour new wine into old bottles).

  reply	other threads:[~2006-04-25 19:39 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
2006-04-25 19:39   ` Drew Adams [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICEEEBDFAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /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 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).