From: Juanma Barranquero <lekktu@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel@gnu.org
Subject: Re: Inconsistency in `string-to-number'
Date: Sat, 5 Sep 2009 02:30:39 +0200 [thread overview]
Message-ID: <f7ccd24b0909041730j3ebfa3f4h5fc4728bb6301272@mail.gmail.com> (raw)
In-Reply-To: <jwvws9axiab.fsf-monnier+emacs@gnu.org>
On Fri, Apr 24, 2009 at 16:06, Stefan Monnier<monnier@iro.umontreal.ca> wrote:
> Actually it could also break code (tho it seems unlikely). I wouldn't
> mind postponing the fix to Emacs-23.2. In the mean time, we need to
> improve the docstring.
The docstring was not improved, and we're now on the 23.2 track, so
time for a reprieve.
Reminder: The problem is the following inconsistency:
(string-to-number "1:") => 1
(string-to-number "1.2:") => 1
(string-to-number "1.2") => 1.2
Alas, the docstring talks about "leading spaces and tabs", but says
nothing about trailing chars.
Currently the behavior, depending of the first non-digit after the
number, is as follows:
- \0, \s, \r, \n, \f and \t => the number is read as a float (if
base == 10) or integer, as intended.
- Any other char: the number is always interpreted as an integer.
Possibilities:
0) Do nothing except clarifying the docs.
Pro: easier of all fixes.
Cons: inconsistency.
1) Disallow any trailing char.
Pro: follows the doc (sort of).
Cons: incompatibility with current uses of undocumented "1:", etc.
2) Allow only whitespace: the same chars that the float case admits right now.
Pro: quite intuitive (IMO), easy to implement.
Cons: Same as 1)
3) Allow any trailing char.
Pro: forgiving.
Cons: (unlikely) incompatibility with uses of undocumented "1.2:" => 1
I like 2), because it seems cleaner to just allow whitespace all
around the number; it has a certain risk of incompatibility, though.
1) and 3) would require adding a new parameter to
lread.c:isfloat_string() or somesuch; not hard, but not very clean.
Thoughts?
Juanma
next prev parent reply other threads:[~2009-09-05 0:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-24 0:16 Inconsistency in `string-to-number' Davis Herring
2009-04-24 10:36 ` Eli Zaretskii
2009-04-24 11:45 ` Juanma Barranquero
2009-04-24 13:19 ` Eli Zaretskii
2009-04-24 14:13 ` Juanma Barranquero
2009-04-24 13:22 ` Stefan Monnier
2009-04-24 13:38 ` Juanma Barranquero
2009-04-24 14:06 ` Stefan Monnier
2009-04-24 14:16 ` Juanma Barranquero
2009-09-05 0:30 ` Juanma Barranquero [this message]
2009-12-01 20:15 ` Stefan Monnier
2009-12-04 3:21 ` Juanma Barranquero
2009-12-04 3:23 ` Juanma Barranquero
2009-12-04 14:22 ` Stefan Monnier
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7ccd24b0909041730j3ebfa3f4h5fc4728bb6301272@mail.gmail.com \
--to=lekktu@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.