Re: [DRAFT][RFC] Big Integer Support

From: Date: Sun, 22 Jun 2014 15:20:30 +0000
Subject: Re: [DRAFT][RFC] Big Integer Support
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-75038@lists.php.net to get a copy of this message
Good afternoon, I’ve made some improvements to the RFC. First, to address Dan’s questions: On 21 Jun 2014, at 12:02, Dan Ackroyd <danack@basereality.com> wrote: > Finally, the RFC should probably address the licensing issues that > would be involved in making GMP an integral part of PHP, not just for > how PHP is distributed, but also for how people making and > distributing PHP applications would be affected. > > For reference the GMP library is dual-licensed under GNU LGPL v3 and > GNU GPL v2.0. As I understand it, these are not compatible with the > PHP license. I’ve now addressed the licensing issues more thoroughly: https://wiki.php.net/rfc/bigint#licensing_and_dependency_issues > Most of all though, it could do with a stronger argument for why > handling bigints 'automagically' like this is preferable to handling > them explicitly. Without great care for handling them, dealing with > very large numbers is still going to fail at some point. Although > handling integers as bigints explicitly is more code to write, it's > also results in more understandable behaviour, which seems better to > me than having more internal converting of types which is not visible > in userland. The opening section now elaborates a little more on why I think bigints are beneficial: https://wiki.php.net/rfc/bigint#introduction I also think that having integers be effectively boundless would be more understandable than how they overflow to floats at the moment, especially for newbie programmers. More generally, it’s less bugs and less worrying about platform differences. Now onto Nikita’s: On 20 Jun 2014, at 15:58, Nikita Popov <nikita.ppv@gmail.com> wrote: > Could you please submit a PR from your branch, so it's possible to review > the code? This has now been done: https://github.com/php/php-src/pull/700 I also lengthened my TODO list for things that are unfinished in the patch: https://wiki.php.net/rfc/bigint#todo > Regarding the RFC text, I think you mixed up some left and right shifts. > "<< 65 will result in zero" is probably supposed to be >> 65? And > "right > shifts will promote to bigints" probably is talking about left shifts? > > Btw, I wouldn't worry about the change in shifts larger than the integer > width. Those have always been UB inherited from using UB of the C language. > The cyclic behavior is only an idiosyncrasy of the x86 architecture - other > ISAs like ARM (iirc) will not exhibit the behavior. I’ve fixed those errors and clarified this a bit, and I also mention that I removed negative shifts, which I had forgotten earlier: https://wiki.php.net/rfc/bigint#changes_to_operators_for_the_sake_of_consistency Thanks for your comments! -- Andrea Faulds http://ajf.me/

« previous php.internals (#75038) next »