Skip to content

Commit 6e1b7ea

Browse files
committed
sv_numeq/sv_numne: consolidate the similar documentation
If nothing else putting them together may avoid someone doing `!sv_numeq(...)`
1 parent e5640e5 commit 6e1b7ea

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

sv.c

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8736,22 +8736,56 @@ S_sv_numcmp_common(pTHX_ SV **sv1, SV **sv2, const U32 flags,
87368736

87378737
=for apidoc sv_numeq
87388738
=for apidoc_item sv_numeq_flags
8739+
=for apidoc_item sv_numne
8740+
=for apidoc_item sv_numne_flags
8741+
8742+
These return a boolean that is the result of the corresponding numeric
8743+
comparison:
8744+
8745+
=over
8746+
8747+
=item C<sv_numeq>
87398748

8740-
These each return a boolean indicating if the numbers in the two SV arguments
8741-
are identical, coercing them to numbers if necessary, basically behaving like
8742-
the Perl code S<C<$sv1 == $sv2>>.
8749+
=item C<sv_numeq_flags>
8750+
8751+
Numeric equality, the same as S<C<$sv1 == $sv2>>.
8752+
8753+
=item C<sv_numne>
8754+
8755+
=item C<sv_numne_flags>
8756+
8757+
Numeric inequality, the same as S<C<$sv1 != $sv2>>.
8758+
8759+
=back
8760+
8761+
Beware that in the presence of overloading C<==> may not be a strict
8762+
inverse of C<!=>.
8763+
8764+
The non-C<_flags> suffix versions of these functions always perform
8765+
get magic and handle the appropriate type of overloading. See
8766+
L<overload> for details.
8767+
8768+
These each return a boolean indicating if the numbers in the two SV
8769+
arguments are equal or not equal, coercing them to numbers if
8770+
necessary, basically behaving like the Perl code.
87438771

87448772
A NULL SV is treated as C<undef>.
87458773

8746-
C<sv_numeq> always performs 'get' magic. C<sv_numeq_flags> performs 'get'
8747-
magic only if C<flags> has the C<SV_GMAGIC> bit set.
8774+
The C<_flags> variants of these functions accept these flags:
87488775

8749-
C<sv_numeq> always checks for, and if present, handles C<==> overloading. If
8750-
not present, regular numerical comparison will be used instead.
8751-
C<sv_numeq_flags> normally does the same, but setting the C<SV_SKIP_OVERLOAD>
8752-
bit set in C<flags> causes it to use regular numerical comparison.
8776+
=over
87538777

8754-
Otherwise, the functions behave identically.
8778+
=item C<SV_GMAGIC>
8779+
8780+
Perform 'get' magic on both C<sv1> amd C<sv2> if this flag is set,
8781+
otherwise 'get' magic is ignored.
8782+
8783+
=item C<SV_SKIP_OVERLOAD>
8784+
8785+
Skip any operator overloading implemented for this type and operator.
8786+
Be aware that numeric, C<+0>, overloading will still be applied, unless in the scope of C<no overloading;>.
8787+
8788+
=back
87558789

87568790
=for apidoc Amnh||SV_SKIP_OVERLOAD
87578791

@@ -8770,32 +8804,6 @@ Perl_sv_numeq_flags(pTHX_ SV *sv1, SV *sv2, const U32 flags)
87708804
return do_ncmp(sv1, sv2) == 0;
87718805
}
87728806

8773-
/*
8774-
8775-
=for apidoc sv_numne
8776-
=for apidoc_item sv_numne_flags
8777-
8778-
These each return a boolean indicating if the numbers in the two SV arguments
8779-
are different, coercing them to numbers if necessary, basically behaving like
8780-
the Perl code S<C<$sv1 != $sv2>>.
8781-
8782-
A NULL SV is treated as C<undef>.
8783-
8784-
C<sv_numne> always performs 'get' magic. C<sv_numne_flags> performs 'get'
8785-
magic only if C<flags> has the C<SV_GMAGIC> bit set.
8786-
8787-
C<sv_numne> always checks for, and if present, handles C<!=> overloading. If
8788-
not present, regular numerical comparison will be used instead.
8789-
C<sv_numne_flags> normally does the same, but setting the C<SV_SKIP_OVERLOAD>
8790-
bit set in C<flags> causes it to use regular numerical comparison.
8791-
8792-
Otherwise, the functions behave identically.
8793-
8794-
=for apidoc Amnh||SV_SKIP_OVERLOAD
8795-
8796-
=cut
8797-
*/
8798-
87998807
bool
88008808
Perl_sv_numne_flags(pTHX_ SV *sv1, SV *sv2, const U32 flags)
88018809
{

0 commit comments

Comments
 (0)