develooper Front page | perl.perl5.porters | Postings from June 2019

[perl #134200] [PATCH] Document SvTRUEx() macro

Thread Previous
From:
perlbug-followup
Date:
June 17, 2019 12:10
Subject:
[perl #134200] [PATCH] Document SvTRUEx() macro
Message ID:
rt-4.0.24-8869-1560773442-518.134200-75-0@perl.org
# New Ticket Created by   
# Please include the string:  [perl #134200]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=134200 >


>From 9dda3b96e0639d0504fea1ab1f9fee4330d7878f Mon Sep 17 00:00:00 2001
From: Pali <pali@cpan.org>
Date: Mon, 17 Jun 2019 14:09:08 +0200
Subject: [PATCH] Document SvTRUEx() macro

---
 sv.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sv.h b/sv.h
index 637cd14dc0..15adf03449 100644
--- a/sv.h
+++ b/sv.h
@@ -1601,10 +1601,21 @@ false.  See C<L</SvOK>> for a defined/undefined test.  Handles 'get' magic
 unless the scalar is already C<SvPOK>, C<SvIOK> or C<SvNOK> (the public, not the
 private flags).
 
+See C<L</SvTRUEx>> for a version which guarantees to evaluate C<sv> only once.
+
 =for apidoc Am|bool|SvTRUE_nomg|SV* sv
 Returns a boolean indicating whether Perl would evaluate the SV as true or
 false.  See C<L</SvOK>> for a defined/undefined test.  Does not handle 'get' magic.
 
+=for apidoc Am|bool|SvTRUEx|SV* sv
+Returns a boolean indicating whether Perl would evaluate the SV as true or
+false.  See C<L</SvOK>> for a defined/undefined test.  Handles 'get' magic
+unless the scalar is already C<SvPOK>, C<SvIOK> or C<SvNOK> (the public, not the
+private flags).
+
+This form guarantees to evaluate C<sv> only once.  Only use this if C<sv> is an
+expression with side effects, otherwise use the more efficient C<SvTRUE>.
+
 =for apidoc Am|char*|SvPVutf8_force|SV* sv|STRLEN len
 Like C<SvPV_force>, but converts C<sv> to UTF-8 first if necessary.
 
-- 
2.11.0


Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About