emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On removing some obsolete code from subr and core


From: Clément Pit--Claudel
Subject: Re: On removing some obsolete code from subr and core
Date: Sat, 5 Nov 2016 13:23:58 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 2016-11-05 12:42, Dmitry Gutov wrote:
> On 05.11.2016 17:52, Clément Pit--Claudel wrote:
> 
>> I never understood this one.  The name string-to-int suggests that you'll 
>> get an error if your string doesn't describe an int.
> 
> I'm just guessing, but that probably never happened. stirng-to-number works 
> like this:
> 
> ELISP> (string-to-number "abc")
> 0 (#o0, #x0, ?\C-@)
> ELISP> (string-to-number "22.2abc")
> 22.2

I know, I know :) (what is this fancy ELISP repl, btw?)

>> How do you get a proper string-to-int behavior in Emacs Lisp? With (let ((v 
>> (string-to-number s))) (when (floatp v) (error …)))?
> 
> By calling `floor' on the result of string-to-number, I guess.

Hmm. I'd expect string-to-int to error on non-ints:

>>> int("1.3")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: invalid literal for int() with base 10: '1.3'

Clément.



Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]