* string-to-number
@ 2005-11-17 4:20 Nick Roberts
2005-11-18 16:56 ` string-to-number Richard M. Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Nick Roberts @ 2005-11-17 4:20 UTC (permalink / raw)
Currently string-to-number gives 0 for a non-number:
(string-to-number "a")^J
0
but
(string-to-number "0")^J
0
gives the same result. So what is a simple test for whether a string
represents a number or not?
If there isn't one, how about:
(string-to-number "a")^J
nil
Of course this means an error is generated if you try to do arithmetic with a
non-number, but I think that this is appropriate and preferable to taking a
value of 0.
Nick
*** data.c 31 Oct 2005 00:56:53 +1300 1.256
--- data.c 17 Nov 2005 16:28:28 +1300
***************
*** 2466,2472 ****
register unsigned char *p;
register int b;
int sign = 1;
! Lisp_Object val;
CHECK_STRING (string);
--- 2466,2472 ----
register unsigned char *p;
register int b;
int sign = 1;
! Lisp_Object val = Qnil;
CHECK_STRING (string);
***************
*** 2506,2514 ****
if (digit < 0)
break;
v = v * b + digit;
}
! val = make_fixnum_or_float (sign * v);
}
return val;
--- 2506,2515 ----
if (digit < 0)
break;
v = v * b + digit;
+ val = Qt;
}
! if (!NILP (val)) val = make_fixnum_or_float (sign * v);
}
return val;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: string-to-number
2005-11-17 4:20 string-to-number Nick Roberts
@ 2005-11-18 16:56 ` Richard M. Stallman
2005-11-19 4:35 ` string-to-number Nick Roberts
0 siblings, 1 reply; 4+ messages in thread
From: Richard M. Stallman @ 2005-11-18 16:56 UTC (permalink / raw)
Cc: emacs-devel
Let's not change this.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: string-to-number
2005-11-18 16:56 ` string-to-number Richard M. Stallman
@ 2005-11-19 4:35 ` Nick Roberts
2005-11-20 23:22 ` string-to-number Richard M. Stallman
0 siblings, 1 reply; 4+ messages in thread
From: Nick Roberts @ 2005-11-19 4:35 UTC (permalink / raw)
Cc: emacs-devel
> Let's not change this.
Before the release? Ever? Don't you think it's an improvement? Are you
concerned about backward compatibility? Are there other reasons?
Nick
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: string-to-number
2005-11-19 4:35 ` string-to-number Nick Roberts
@ 2005-11-20 23:22 ` Richard M. Stallman
0 siblings, 0 replies; 4+ messages in thread
From: Richard M. Stallman @ 2005-11-20 23:22 UTC (permalink / raw)
Cc: emacs-devel
> Let's not change this.
Before the release? Ever? Don't you think it's an improvement? Are you
concerned about backward compatibility? Are there other reasons?
I can't afford to spend time thinking about minor issues, and I don't
want them causing any trouble, so I made a quick simple decision: we
will keep this unchanged. Would you please let it drop?
There are two kinds of changes we should consider now:
1. Bug fixes.
2. Changes in new features, to get them right the first
time they are released.
Please don't propose other kinds of changes. It would be ideal not to
even mention issues other than those two categories.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-11-20 23:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-17 4:20 string-to-number Nick Roberts
2005-11-18 16:56 ` string-to-number Richard M. Stallman
2005-11-19 4:35 ` string-to-number Nick Roberts
2005-11-20 23:22 ` string-to-number Richard M. Stallman
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.