Re: [STANDARDS] Integer operations are implementation-defined

[email protected] (Andrea Faulds)
Newsgroups php.standards
Message-ID <[email protected]>
On 8 Aug 2014, at 23:33, Drew Paroski <[email protected]> wrote:

> Thanks for taking the time to further elaborate your position. If I'm hearing
> you correctly, the main points you're putting forth seem to be (1) int->float
> promotion is not as crappy as int wraparound for users, (2) there are a good
> number of use cases where the int->float promotion is what users want or what
> causes the least surprise for users, (3) the performance hit of having to
> support int->float promotion is minor, (4) this behavior has been around for a
> long time and while most apps don't depend on it, there are a small percentage
> that do, (5) the bigint RFC might never land, or it might not land for a while,
> and so in the meantime the spec should specify the existing php.net behavior
> that some apps in the wild currently rely on, and (6) given all the points
> above, it seems like a win to avoid making integer overflow an issue where
> users have to worry about different implementations doing different things.

Yep. That’s actually a much better and more succinct summary of my own argument than I could have possibly written. :)

> I think your argument makes a lot of sense. Thinking about the issue more, it
> seems like requiring int->float promotion on integer overflow is not
> unreasonable. My main concern was avoiding the slippery slope of arguing that
> the spec should always require the exact behavior of php.net PHP down to the
> last detail. It sounds like there are some good reasons for requiring
> int->float promotion aside from "this is how php.net PHP does it" :)
> 
> Thanks again for entertaining my feedback and questions.

Ah, I see. While I do have a certain bias towards what php.net PHP does, I wouldn’t say I’m necessarily in favour of always doing what php.net does, I just feel that way on this specific issue. Generally I want us to standardise on just one way to do most things unless there’s a particularly good reason. For example, float to int conversion is an unfortunate one as php.net PHP doesn’t consistently cast things like NaN and Infinity to the same integer values. :/

Thanks!

--
Andrea Faulds
http://ajf.me/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.