Skip to content

Implemented %% integer division operator #724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

hikari-no-yume
Copy link
Contributor

https://wiki.php.net/rfc/intdiv

There's also a pull request that just adds a function to ext/standard instead, in case I can't get the operator in: #722

@nikic
Copy link
Member

nikic commented Jul 16, 2014

Huge -1 on this, %% as an integer division operator is totally unclear.

@hikari-no-yume
Copy link
Contributor Author

It's one of the few sane syntax choices IMO, I'd prefer that over \\, div or intdiv.

@datibbaw
Copy link
Contributor

Although it has no potential for name clashes, I agree that with % being the remainder, having %% return the division is unintuitive at best.

@hikari-no-yume
Copy link
Contributor Author

Sure, but I can't think of a better choice. :/

@smalyshev
Copy link
Contributor

I don't like %% too much either. Also, what about gmp? I don't see this patch updating gmp to support the new operator.

@smalyshev
Copy link
Contributor

Also, tokenizer tests are unhappy.

@hikari-no-yume
Copy link
Contributor Author

On 16 Jul 2014, at 18:36, Stanislav Malyshev [email protected] wrote:

I don't like %% too much either. Also, what about gmp? I don't see this patch updating gmp to support the new operator.

Somehow I managed to think of doing it for my bigints patch but not for the gmp extension, I’ll do that, my bad.

Andrea Faulds
http://ajf.me/

@hikari-no-yume
Copy link
Contributor Author

@smalyshev I'm unable to reproduce the tokeniser issue on my machine.

@smalyshev
Copy link
Contributor

@TazeTSchnitzel still not the reason to break CI :)

@hikari-no-yume
Copy link
Contributor Author

Sure... I'll try and figure out what's up.

@hikari-no-yume
Copy link
Contributor Author

@smalyshev Fixed it. It "didn't happen on my machine" because I compiled with --disable-all and somehow missed that the test was in ext/tokenizer.

@hikari-no-yume
Copy link
Contributor Author

@datibbaw I'd argue it does make some sort of sense, it's just rather backwards: % returns the remainder, %% returns the quotient.

@smalyshev
Copy link
Contributor

If only we didn't use \ for namespaces, we could use it here like some other languages do...

@hikari-no-yume
Copy link
Contributor Author

Yeah, Visual Basic does that and it's a good choice. // is used by Python. Maybe we could use \\? (Is that a terrible or a brilliant idea?)

@smalyshev
Copy link
Contributor

No, \ is already used in namespaces, we can not use it without creating an ambiguity.

@hikari-no-yume
Copy link
Contributor Author

Right, but would the double-backslash work? Can you have a blank namespace?

@smalyshev
Copy link
Contributor

You can not use \ for namespace, but I don't think it is a good idea to reuse namespace syntax for completely unrelated operator.

@hikari-no-yume
Copy link
Contributor Author

Yeah, that's the problem. %% is weird but I think it's the most sensible (and I suppose it makes sense as a % counterpart in a twisted way) of the available options.

@laruence
Copy link
Member

I don't like this %%. ........... -1

@hikari-no-yume
Copy link
Contributor Author

RFC was rejected, so this request is closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants