Re: [RFC] intdiv()

From: Date: Thu, 17 Jul 2014 06:44:07 +0000
Subject: Re: [RFC] intdiv()
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-75646@lists.php.net to get a copy of this message
On 17 Jul 2014, at 07:29, Zeev Suraski <zeev@zend.com> wrote: > From debating whether it's worth it to add a new function for an > not-so-commonly-used-operation-to-say-the-least, we're now seriously > considering adding a new language level operator? Really? Is it *really* not that common? I can think of several use-cases off the top of my head: * Time (actually pretty common in web apps, though we have a DateTime class) * Splitting into rows and columns * Pagination * Currency (you can’t, for example, represent the full number of BTC in circulation in BTC's base unit without using an integer of beyond 53-bits, and it’s common practise to use *fixed-point* arithmetic here) * Nearest-neighbour scaling * Most likely other ones (these are just what I thought of immediately) Also, while ** is great for some applications, it’s not going to be used much by others. Is the same not true of an integer division operator? On 17 Jul 2014, at 07:31, Zeev Suraski <zeev@zend.com> wrote: > I can't believe we're seriously considering adding an operator for something > so uncommon. > > I'm actually in favor of adding APIs, but absolutely not an obscure > operator. We're not Perl. Nor are we Python, but it is worth looking at just how many other languages support this considering it’s actually very useful in some situations. I can think of C, C++, C#, Java, Objective-C, Visual Basic, Pascal, Python and Ruby to name a few popular ones. If you say that some of these implement it just because C does, I’m not sure that’s fair, as there are plenty of bad ideas in C which these don’t implement. -- Andrea Faulds http://ajf.me/

« previous php.internals (#75646) next »