From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Drew Adams" Newsgroups: gmane.emacs.devel Subject: RE: changing function signatures and no library version # => must use too-general test Date: Tue, 25 Apr 2006 12:39:37 -0700 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1145996154 30919 80.91.229.2 (25 Apr 2006 20:15:54 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 25 Apr 2006 20:15:54 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Apr 25 22:15:53 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1FYTwo-0006q5-BD for ged-emacs-devel@m.gmane.org; Tue, 25 Apr 2006 22:15:46 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYTwn-0000jp-Tz for ged-emacs-devel@m.gmane.org; Tue, 25 Apr 2006 16:15:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYTum-0007z6-Hw for emacs-devel@gnu.org; Tue, 25 Apr 2006 16:13:40 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYTuj-0007x8-Pb for emacs-devel@gnu.org; Tue, 25 Apr 2006 16:13:40 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYTuj-0007wx-Cn for emacs-devel@gnu.org; Tue, 25 Apr 2006 16:13:37 -0400 Original-Received: from [199.232.41.67] (helo=mx20.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FYTx5-0006aC-2n for emacs-devel@gnu.org; Tue, 25 Apr 2006 16:16:03 -0400 Original-Received: from [148.87.113.118] (helo=rgminet01.oracle.com) by mx20.gnu.org with esmtp (Exim 4.52) id 1FYTQw-0001QC-P8 for emacs-devel@gnu.org; Tue, 25 Apr 2006 15:42:51 -0400 Original-Received: from rgmsgw300.us.oracle.com (rgmsgw300.us.oracle.com [138.1.186.49]) by rgminet01.oracle.com (Switch-3.1.6/Switch-3.1.6) with ESMTP id k3PJdd0G013243 for ; Tue, 25 Apr 2006 13:39:39 -0600 Original-Received: from dradamslap (dhcp-amer-csvpn-gw2-141-144-74-251.vpn.oracle.com [141.144.74.251]) by rgmsgw300.us.oracle.com (Switch-3.1.7/Switch-3.1.7) with SMTP id k3PJdcYC020745 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Tue, 25 Apr 2006 13:39:39 -0600 Original-To: "Emacs-Devel" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.6604 (9.0.2911.0) In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Importance: Normal X-Brightmail-Tracker: AAAAAQAAAAI= X-Brightmail-Tracker: AAAAAQAAAAI= X-Whitelist: TRUE X-Whitelist: TRUE X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:53414 Archived-At: > 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).