From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Re: Inconsistency in `string-to-number' Date: Sat, 5 Sep 2009 02:30:39 +0200 Message-ID: References: <47083.128.165.123.18.1240532205.squirrel@webmail.lanl.gov> <833abygwxo.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1252110728 25677 80.91.229.12 (5 Sep 2009 00:32:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 5 Sep 2009 00:32:08 +0000 (UTC) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Sep 05 02:32:00 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 1MjjCB-0003Oa-BI for ged-emacs-devel@m.gmane.org; Sat, 05 Sep 2009 02:31:59 +0200 Original-Received: from localhost ([127.0.0.1]:47321 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjjCA-0001Nr-KW for ged-emacs-devel@m.gmane.org; Fri, 04 Sep 2009 20:31:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MjjBK-00010v-Qp for emacs-devel@gnu.org; Fri, 04 Sep 2009 20:31:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MjjBG-000109-6n for emacs-devel@gnu.org; Fri, 04 Sep 2009 20:31:06 -0400 Original-Received: from [199.232.76.173] (port=59985 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MjjBG-000106-3g for emacs-devel@gnu.org; Fri, 04 Sep 2009 20:31:02 -0400 Original-Received: from mail-bw0-f220.google.com ([209.85.218.220]:43096) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MjjBE-0006oz-CQ; Fri, 04 Sep 2009 20:31:00 -0400 Original-Received: by bwz20 with SMTP id 20so1070999bwz.42 for ; Fri, 04 Sep 2009 17:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=3ZLRqIZQuRuWD/vSvXR0BN7gvO9hDDvS8yShUr0ii/g=; b=xblBDgRBejXKNqnaFvQrRHbEzZZtmzq6vHkx6iy3pnJ/ohPtKyIN9w8IXd0UbMny03 uhvN6YEnudPFWdNcO8LwEUB/KSn3Mxnb1B3p3Cuc4JAPa2i4RmySkrWLGFOgRmwLM9G6 ob/3y0DocVfFbmYdrOFEiSy3tT8IF9pR9rgDc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=NC3wHl2rYMwCs4sLY4NrrBzYQa2LK1z/648QDOFfTBDySxIor5wgCJX3OVyiM7tOI7 VIYLjLddGolsndMNynMpLwD7HKUf/ZTSVZIfC1b9tFp6c7Dq51Yqng8ZDBHKlXOVvzcf uakit9KGkX2i0gMHRvVmBfOAbhjxuRT7UhKzw= Original-Received: by 10.239.182.163 with SMTP id q35mr1061795hbg.70.1252110659077; Fri, 04 Sep 2009 17:30:59 -0700 (PDT) In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) 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:115039 Archived-At: On Fri, Apr 24, 2009 at 16:06, Stefan Monnier wro= te: > Actually it could also break code (tho it seems unlikely). =C2=A0I wouldn= 't > mind postponing the fix to Emacs-23.2. =C2=A0In 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:") =3D> 1 (string-to-number "1.2:") =3D> 1 (string-to-number "1.2") =3D> 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 =3D> the number is read as a float (if base =3D=3D 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:" =3D>= 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