From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: florian@fsavigny.de (Florian v. Savigny) Newsgroups: gmane.emacs.help Subject: Re: Rationale behind conversion of a nil prefix arg to numeric 1 Date: Tue, 06 Sep 2016 15:27:22 +0200 Message-ID: <87oa41yx8l.fsf@bertrandrussell.Speedport_W_723V_1_40_000> References: <87y437c0qg.fsf@bertrandrussell.Speedport_W_723V_1_40_000> <83oa43d9r8.fsf@gnu.org> <06d4a7f1-f116-fb5c-9bd2-c4d1f98934c9@easy-emacs.de> <83k2ercy5u.fsf@gnu.org> <83bn02cs54.fsf@gnu.org> <83ed1411-dbc1-2fe1-5fe9-4fdc7a4d1b21@online.de> <83shteb26t.fsf@gnu.org> <20160906071015.GB15537@tuxteam.de> <87inu98ipz.fsf@bertrandrussell.Speedport_W_723V_1_40_000> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1473170002 14785 195.159.176.226 (6 Sep 2016 13:53:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 6 Sep 2016 13:53:22 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Sep 06 15:53:19 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bhGoM-00031u-Sd for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Sep 2016 15:53:15 +0200 Original-Received: from localhost ([::1]:33585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGoK-0000mu-Ns for geh-help-gnu-emacs@m.gmane.org; Tue, 06 Sep 2016 09:53:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGPQ-0004SC-U4 for help-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:27:30 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bhGPN-0005kE-6N for help-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:27:27 -0400 Original-Received: from srv4.ns-domain-hosting.de ([178.63.89.203]:55139) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bhGPM-0005jf-TG for help-gnu-emacs@gnu.org; Tue, 06 Sep 2016 09:27:25 -0400 X-No-Relay: not in my network Original-Received: from bertrandrussell.Speedport_W_723V_1_40_000 (p3E9EEF0C.dip0.t-ipconnect.de [62.158.239.12]) by srv4.ns-domain-hosting.de (Postfix) with ESMTPSA id 9429C186441 for ; Tue, 6 Sep 2016 15:27:23 +0200 (CEST) In-reply-to: (message from Andreas =?windows-1252?Q?R=F6hler?= on Tue, 6 Sep 2016 13:27:39 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 178.63.89.203 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:111284 Archived-At: > IIUC `prefix-numeric-value' is a more complex thing than providing a=20 > repeat counter - which it does for lower p. I thought I had understood that (interactive (list (prefix-numeric-value current-prefix-arg))) was exactly the same as (interactive "p") Or isn't it? Then I am really confused. (But a test I just ran seems to confirm that it is.) > But let's go back to the simplest case of lower p in interactive spec= : >=20 > What is easier to read/grasp >=20 > (setq counter (or arg 1) >=20 > or >=20 > (setq counter (prefix-numeric-value arg)) Or, alternatively, (defun foo (counter) (interactive "p") ... ) (But of course, only if I have understood that correctly.) But as to your question: Of course your first suggestion is easier to grasp. But IIHUC, one would normally do it the way I have just sketched, and the idea of the "numeric prefix arg" was probably to supply an easy (i.e. short) way to use the prefix arg as a repeat counter. And if my example is correct, that solution isn't that bad. BTW, I have just understood another interesting detail: That there ALWAYS is a prefix arg, even if the user does not supply one, and you do not have to say (defun foo (&optional counter) (interactive "p") ... ) in the specific case where your optional arg is the prefix arg. That, arguably, also adds idiosyncrasy. > IOW: in favor of avoiding these complex, tricky things. Let's have th= e=20 > code as explicit as possible. I totally agree, but as Eli has pointed out, Elisp was designed the way it was designed a long while back. I guess prefix args have been around almost since the very beginnings. Changing something about very fundamental things like that would mean having to change A LOT OF very fundamental code, without breaking anything. The question then would simply be: Who is up for this job? In other words, even though I like Emacs a lot, I think it is only fair to call Elisp idiosyncratic in some ways. But if it is worth fixing these, I think, is simply what Eli might call a question for a rainy day. I presume that the things that seem so idiosyncratic or somewhat obscure about Elisp (e.g. not only prefix args, but also the way lists are constructed, the reason why there are several kinds of sequences, obarrays) were not deliberately designed to be hard to understand (or to make Emacs privy to the initiated only), but that all had a lot to do with the technical limitations at the time. (Meaning there was perhaps not even a real alternative.) So now they are there, and changing them now would have very different consequences than deciding on a feature when you design a language anew has. (FWIW, I think this is precisely the reason why Larry Wall decided to break compatibility between Perl 5 and Perl 6, making Perl 6 simply a new language. Accidently, one of the design goals of Perl 6 was: being more intuitive than Perl 5.) On the other hand, when I read the node "Command Loop -> Prefix Command Arguments" in the Elisp Manual, I wonder how anyone CANNOT be confused about prefix args, because this node starts out with the unfortunate sentence: Most Emacs commands can use a "prefix argument", a number specified before the command itself. If I am not mistaken, this promotes precisely the misunderstanding that I had fallen prey to. In contrast, other unintuitive features of Elisp are quite well explained in the manual. (List construction -- the cons cell stuff -- and sequences are two things I remember understanding quite readily from reading it, and in both cases it would never have occurred to me to intuitively assume they worked like that.) Maybe it would be a good idea if somebody simply rewrote some of the /documentation/ on prefix args, such that the innocent, naive user understands the point of the two representations? Because that is something that can be easily rewritten without breaking any code. I'll volunteer for the job if somebody checks! --=20 Florian von Savigny Melanchthonstr. 41 33615 Bielefeld