-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update gmp+bcmath parameter names #6205
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
Conversation
Okay, I just looked at ext/bcmath as well, and realized that it would make sense to consider these two extensions together, as there's a good bit of overlap. bcmath uses $left_operand and $right_operand in places, so $lhs/$rhs, $left/$right might be possibilities instead of $num1/$num2. However, this doesn't generalize, e.g. speaking about a left and a right hand side of a Legendre symbol makes little sense (it would be more like, top and bottom). bcmath also uses $dividend and $divisor for divisions in particular. I'm not fond of that, because I always forget which one is which. |
|
||
function gmp_mod(GMP|int|string $a, GMP|int|string $b): GMP {} | ||
function gmp_mod(GMP|int|string $num1, GMP|int|string $num2): GMP {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function gmp_mod(GMP|int|string $num1, GMP|int|string $num2): GMP {} | |
function gmp_mod(GMP|int|string $num, GMP|int|string $mod): GMP {} |
To align with BCMath?
EDIT: Got confused by bcpowmod()
I do prefer $num1/$num2 as except for subtraction it's kinda irrelevant what the order is.
Maybe using |
ext/bcmath/bcmath.stub.php
Outdated
|
||
function bcpowmod(string $base, string $exponent, string $modulus, ?int $scale = null): string {} | ||
function bcpowmod(string $base, string $exp, string $mod, ?int $scale = null): string {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH I liked $exponent
and $modulus
a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've restored $exponend/$modulus here and used them on the GMP side as well.
ext/gmp/gmp.stub.php
Outdated
|
||
function gmp_rootrem(GMP|int|string $a, int $nth): array {} | ||
function gmp_rootrem(GMP|int|string $num, int $nth): array {} | ||
|
||
function gmp_pow(GMP|int|string $base, int $exp): GMP {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although $base
is certainly a good name, but wouldn't it make sense to use $num
instead when nearly all the other functions use this term?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, makes sense. I've switched this to use $num
.
Looks good ✅ |
GMP doesn't have much in terms of meaningful parameter names... I went with num1/num2 in favor of a, b.