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: interactive-p and called-interactively-p Date: Sun, 16 Aug 2009 15:40:28 -0700 Message-ID: References: <8AD328622F5645B282D1E72CB4582EF3@us.oracle.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1250462431 14768 80.91.229.12 (16 Aug 2009 22:40:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 16 Aug 2009 22:40:31 +0000 (UTC) Cc: emacs-devel@gnu.org To: , "'Stefan Monnier'" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Aug 17 00:40:24 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1McoOk-0003AM-VO for ged-emacs-devel@m.gmane.org; Mon, 17 Aug 2009 00:40:23 +0200 Original-Received: from localhost ([127.0.0.1]:51493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1McoOk-0006cJ-5R for ged-emacs-devel@m.gmane.org; Sun, 16 Aug 2009 18:40:22 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1McoOf-0006c4-5Z for emacs-devel@gnu.org; Sun, 16 Aug 2009 18:40:17 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1McoOa-0006bs-JJ for emacs-devel@gnu.org; Sun, 16 Aug 2009 18:40:16 -0400 Original-Received: from [199.232.76.173] (port=53027 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1McoOa-0006bp-FU for emacs-devel@gnu.org; Sun, 16 Aug 2009 18:40:12 -0400 Original-Received: from acsinet11.oracle.com ([141.146.126.233]:22508) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1McoOX-0000aG-Fh; Sun, 16 Aug 2009 18:40:09 -0400 Original-Received: from acsinet15.oracle.com (acsinet15.oracle.com [141.146.126.227]) by acsinet11.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7GMeinW021257 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 16 Aug 2009 22:40:45 GMT Original-Received: from abhmt010.oracle.com (abhmt010.oracle.com [141.146.116.19]) by acsinet15.oracle.com (Switch-3.3.1/Switch-3.3.1) with ESMTP id n7GMei5D001637; Sun, 16 Aug 2009 22:40:44 GMT Original-Received: from dradamslap1 (/141.144.88.37) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 16 Aug 2009 15:40:03 -0700 X-Mailer: Microsoft Office Outlook 11 Thread-Index: Acoet9LrOUwFMKhNRWK8v3RpWEowNAAA99lw In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Source-IP: abhmt010.oracle.com [141.146.116.19] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090202.4A888AC4.0054:SCFSTAT5015188,ss=1,fgs=0 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 1) 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:114328 Archived-At: > > It would have been far better to just add an optional > > argument to `interactive-p' than to create a new, > > similarly named function. > > Agreed. Any objection? > > I object. Two different names makes it easier to remember the > difference. That might be true, IF the names in question actually suggested the difference. But you can understand nothing of the difference by looking at these particular function names. All you can tell is that they are different functions (duh), but with names that seem to say the same thing (huh?). To understand the difference, you must then compare two doc strings that are very similar, looking for a difference. Or read the manual and compare the descriptions there. In either case, the work you need to do to understand the difference is far more than what is needed to understand what the optional arg K-MACRO-P does. (And that's probably at least partly behind why the current doc for these is almost incomprehensible and not entirely correct.) > An argument would be harder to remember. Harder to remember what, that there ARE two possible behaviors? Or WHAT those behaviors are? This is what arguments are all about - the basic function is the same, but its behavior depends a bit on its args. In this case, the function names do NOT help you remember WHAT the difference is. (The doc can't even seem to get it right.) Having a single function with its alternative behaviors described in terms of an optional arg is much clearer. And even seeing just the signature (with `&optional K-MACRO-P') clarifies the meaning and helps remembering - it's obvious from just the signature that the behavior difference is about keyboard macros. The most important thing to "remember" about these two functions is in fact that they do essentially the SAME thing. They differ only in the K-MACRO-P aspect. The basic function is the same. So first you have to know that there are two such functions, and then you have to look them both up, to be sure to get the right one. If you only know about one of the functions (I'll bet that that's the case today for many Elisp programmers), then you risk using the wrong one (the only one you know). If you know there are two, you still need to look them both up, to recall which is which. > The name `called-interactively-p' is good because > it relates to the use of `interactive'. The name `interactive-p' > is confusing because it does NOT relate. I'm not convinced, but I have no problem with that: deprecate `interactive-p' in that case. > Perhaps we should make the name `interactive-p' obsolete > and make a new name, `from-user-input-p'. This will eliminate > the confusion completely. OK with making one of the two functions (or both) obsolete. I don't really care what name is retained for the merged function. FWIW - Of the 3 names mentioned here, my own preference would probably be first `interactive-p', then `called-interactively-p', and last `from-user-input-p' (not very helpful, IMO). But I have no problem with any name that suggests what this does in a general way. For me, the basic function it performs is to test whether the current invocation was made interactively. [Yes, that means invoked via `call-interactively', which is why `called-interactively-p' is not bad. But we have already seen some confusion surrounding `called-interactively-p' and `call-interactively'. `interactive-p' is better in a sense, because it is higher level. Some users might not realize that interactive invocation always means invocation through `call-interactively', even when `call-interactively' might not appear explicitly in the Lisp source code. A name such as `invoked-interactively-p', which of course means the same thing as `called-interactively-p', doesn't lend itself to such confusion. (Of course, introducing a third name at this point does imply even more adjustment of existing code.)]