unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Andreas Röhler" <andreas.roehler@easy-emacs.de>
To: Kaushal Modi <kaushal.modi@gmail.com>, help-gnu-emacs@gnu.org
Subject: Re: Rationale behind conversion of a nil prefix arg to numeric 1
Date: Tue, 6 Sep 2016 18:44:16 +0200	[thread overview]
Message-ID: <9b1324d4-ec20-5924-907e-601af94622fc@easy-emacs.de> (raw)
In-Reply-To: <CAFyQvY1+zDybJu0tctF9jb3+bu2qWp4JqM6yCp1wFpSH1L5Orw@mail.gmail.com>



On 06.09.2016 16:20, Kaushal Modi wrote:
> On Tue, Sep 6, 2016, 7:22 AM Andreas Röhler 
> <andreas.roehler@easy-emacs.de <mailto:andreas.roehler@easy-emacs.de>> 
> wrote:
>
>     But let's go back to the simplest case of lower p in interactive spec:
>
>     What is easier to read/grasp
>
>     (setq counter (or arg 1)
>
>     or
>
>     (setq  counter (prefix-numeric-value arg))
>
>     IOW: in favor of avoiding these complex, tricky things. Let's have the
>     code as explicit as possible.
>
>
> Those 2 forms are not 100℅ equivalent. The equivalence goes only as 
> far as setting the default value of counter.
>
> If the user used (interactive "p"), counter need to be set to 4 
> regardless of whether the user used "C-4" as prefix or "C-u". In the 
> former case, arg would be "4", but in the latter case, it would be 
> "(4)", I.e. a list, not a number.

Not sure IIUC

(defun whatarg-p (arg)
   (interactive "p")
   (message "%s" arg))

Called with simply C-u without numeric argument gives me "4"

(4) would be the result with uppercase P

> Your simpler representation would not take care of the C-u case. If 
> the counter variable is used where a numeric arg is strictly required, 
> you will get an error. Here, prefix-numeric-value returns "4" when arg 
> is "(4)".
>
> -- 
>
> Kaushal Modi
>



  reply	other threads:[~2016-09-06 16:44 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-04 12:23 Rationale behind conversion of a nil prefix arg to numeric 1 Florian v. Savigny
2016-09-04 14:23 ` Eli Zaretskii
2016-09-04 17:11   ` Andreas Röhler
2016-09-04 18:33     ` Eli Zaretskii
2016-09-05  7:16       ` Andreas Röhler
2016-09-05 14:56         ` Eli Zaretskii
2016-09-05 15:22           ` Kaushal Modi
2016-09-05 16:32             ` Drew Adams
2016-09-05 18:41             ` Andreas Röhler
2016-09-05 19:02               ` Eli Zaretskii
2016-09-06  7:10                 ` tomas
2016-09-06  9:45                   ` Florian v. Savigny
2016-09-06 10:27                     ` tomas
2016-09-06 11:27                     ` Andreas Röhler
2016-09-06 13:27                       ` Florian v. Savigny
2016-09-06 15:22                         ` Drew Adams
2016-09-06 14:20                       ` Kaushal Modi
2016-09-06 16:44                         ` Andreas Röhler [this message]
2016-09-06 16:41                           ` Kaushal Modi
2016-09-07 23:11                         ` Charles Millar
2016-09-08 13:10                           ` Kaushal Modi
2016-09-08 14:42                             ` Charles Millar
2016-09-08 15:40                           ` Drew Adams
2016-09-06  7:22                 ` Andreas Röhler
2016-09-05 17:04         ` Drew Adams
2016-09-05 21:39           ` Florian v. Savigny
     [not found]           ` <<877faqvxfp.fsf@bertrandrussell.Speedport_W_723V_1_40_000>
2016-09-05 23:32             ` Drew Adams
2016-09-06  3:45               ` B.V. Raghav
2016-09-04 22:53   ` Florian v. Savigny
     [not found]   ` <<87d1kjjmys.fsf@bertrandrussell.Speedport_W_723V_1_40_000>
2016-09-05  0:52     ` Drew Adams
2016-09-15 12:47 ` Thien-Thi Nguyen

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=9b1324d4-ec20-5924-907e-601af94622fc@easy-emacs.de \
    --to=andreas.roehler@easy-emacs.de \
    --cc=help-gnu-emacs@gnu.org \
    --cc=kaushal.modi@gmail.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.
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).