Skip to content

Commit c28118d

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 d65f56a commit c28118d

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
@@ -8742,22 +8742,56 @@ S_sv_numcmp_common(pTHX_ SV **sv1, SV **sv2, const U32 flags,
87428742

87438743
=for apidoc sv_numeq
87448744
=for apidoc_item sv_numeq_flags
8745+
=for apidoc_item sv_numne
8746+
=for apidoc_item sv_numne_flags
8747+
8748+
These return a boolean that is the result of the corresponding numeric
8749+
comparison:
8750+
8751+
=over
8752+
8753+
=item C<sv_numeq>
87458754

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

87508778
A NULL SV is treated as C<undef>.
87518779

8752-
C<sv_numeq> always performs 'get' magic. C<sv_numeq_flags> performs 'get'
8753-
magic only if C<flags> has the C<SV_GMAGIC> bit set.
8780+
The C<_flags> variants of these functions accept these flags:
87548781

8755-
C<sv_numeq> always checks for, and if present, handles C<==> overloading. If
8756-
not present, regular numerical comparison will be used instead.
8757-
C<sv_numeq_flags> normally does the same, but setting the C<SV_SKIP_OVERLOAD>
8758-
bit set in C<flags> causes it to use regular numerical comparison.
8782+
=over
87598783

8760-
Otherwise, the functions behave identically.
8784+
=item C<SV_GMAGIC>
8785+
8786+
Perform 'get' magic on both C<sv1> amd C<sv2> if this flag is set,
8787+
otherwise 'get' magic is ignored.
8788+
8789+
=item C<SV_SKIP_OVERLOAD>
8790+
8791+
Skip any operator overloading implemented for this type and operator.
8792+
Be aware that numeric, C<+0>, overloading will still be applied, unless in the scope of C<no overloading;>.
8793+
8794+
=back
87618795

87628796
=for apidoc Amnh||SV_SKIP_OVERLOAD
87638797

@@ -8776,32 +8810,6 @@ Perl_sv_numeq_flags(pTHX_ SV *sv1, SV *sv2, const U32 flags)
87768810
return do_ncmp(sv1, sv2) == 0;
87778811
}
87788812

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

0 commit comments

Comments
 (0)