Re: [RFC] intdiv()
| From: | Kris Craig | Date: | Thu, 17 Jul 2014 03:02:22 +0000 |
| Subject: | Re: [RFC] intdiv() | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75630@lists.php.net to get a copy of this message | ||
On Tue, Jul 15, 2014 at 5:13 AM, Andrea Faulds <ajf@ajf.me> wrote:
>
> On 15 Jul 2014, at 06:50, Kris Craig <kris.craig@gmail.com> wrote:
>
> > While a practical argument can certainly be made that existing solutions
> can fit the examples OP cited, I don't think that takes away from the
> underlying principle of the argument: That there's no reason *not* to
> include a basic integer division in PHP. It's never made sense to me why
> it wasn't included. Rather than an intdiv() function, though, I wonder if
> an operator would be a better approach. Some languages I've seen that use
> / as the division operator will use a \ as the integer division operator.
>
> We use \ for namespaces, and Python 3’s // obviously can’t be used, so I
> might suggest Pascal’s div operator:
>
Oh, derp.
On Wed, Jul 16, 2014 at 5:11 PM, Bishop Bettini <bishop@php.net> wrote:
> As another contender, how about:
>
> $x = 242 %/ 7;
> $x %/= 13;
>
I like this idea! I haven't seen anyone else respond to it yet, though.
My only question would be whether %/ or /% would be more appropriate.
Perhaps the RFC could have two options for approval; one with %% and the
other with either %/ or /%. Thoughts?
--Kris