[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Rationale behind conversion of a nil prefix arg to numeric 1
From: |
Kaushal Modi |
Subject: |
Re: Rationale behind conversion of a nil prefix arg to numeric 1 |
Date: |
Tue, 06 Sep 2016 14:20:02 +0000 |
On Tue, Sep 6, 2016, 7:22 AM Andreas Röhler <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. 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
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, (continued)
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Kaushal Modi, 2016/09/05
- RE: Rationale behind conversion of a nil prefix arg to numeric 1, Drew Adams, 2016/09/05
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Andreas Röhler, 2016/09/05
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Eli Zaretskii, 2016/09/05
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, tomas, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Florian v. Savigny, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, tomas, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Andreas Röhler, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Florian v. Savigny, 2016/09/06
- RE: Rationale behind conversion of a nil prefix arg to numeric 1, Drew Adams, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1,
Kaushal Modi <=
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Andreas Röhler, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Kaushal Modi, 2016/09/06
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Charles Millar, 2016/09/07
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Kaushal Modi, 2016/09/08
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Charles Millar, 2016/09/08
- RE: Rationale behind conversion of a nil prefix arg to numeric 1, Drew Adams, 2016/09/08
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Andreas Röhler, 2016/09/06
- RE: Rationale behind conversion of a nil prefix arg to numeric 1, Drew Adams, 2016/09/05
- Re: Rationale behind conversion of a nil prefix arg to numeric 1, Florian v. Savigny, 2016/09/05
- RE: Rationale behind conversion of a nil prefix arg to numeric 1, Drew Adams, 2016/09/05