In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/c9fe309b988eb6db0705de33e24381da2b3761eb?hp=fde84d2e7382e53c871f09ac324785f8accc38b3>

- Log -----------------------------------------------------------------
commit c9fe309b988eb6db0705de33e24381da2b3761eb
Author: David Mitchell <[email protected]>
Date:   Fri Aug 4 11:50:07 2017 +0100

    pod/perltie.pod: mention SCALAR() for boolean keys
    
    After a recent commit of mine, SCALAR() is now called by 'keys' in boolean
    context, e.g.
    
        if (keys %tied) { ... }
    
    update the docs to reflect this. See the thread
    
        http://nntp.perl.org/group/perl.perl5.porters/245463

M       pod/perltie.pod

commit d24f6c9be3a37fb78fb01ef4ae0c5ec13ad4e685
Author: David Mitchell <[email protected]>
Date:   Fri Aug 4 09:48:06 2017 +0100

    SvTRUE(): add code comment
    
    explain that the '!= 0' is acting as a bool cast (since SvTRUE() is
    supposed to return a bool value rather than an int value).

M       sv.h
-----------------------------------------------------------------------

Summary of changes:
 pod/perltie.pod | 12 +++++++-----
 sv.h            |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/pod/perltie.pod b/pod/perltie.pod
index 87a21268ed..5ee19c09ec 100644
--- a/pod/perltie.pod
+++ b/pod/perltie.pod
@@ -504,8 +504,9 @@ reports whether a key is present in the hash, and DELETE 
deletes one.
 CLEAR empties the hash by deleting all the key and value pairs.  FIRSTKEY
 and NEXTKEY implement the keys() and each() functions to iterate over all
 the keys. SCALAR is triggered when the tied hash is evaluated in scalar 
-context. UNTIE is called when C<untie> happens, and DESTROY is called when
-the tied variable is garbage collected.
+context, and in 5.28 onwards, by C<keys> in boolean context. UNTIE is
+called when C<untie> happens, and DESTROY is called when the tied variable
+is garbage collected.
 
 If this seems like a lot, then feel free to inherit from merely the
 standard Tie::StdHash module for most of your methods, redefining only the
@@ -805,9 +806,10 @@ thing, but we'll have to go through the LIST field 
indirectly.
 =item SCALAR this
 X<SCALAR>
 
-This is called when the hash is evaluated in scalar context. In order
-to mimic the behaviour of untied hashes, this method should return a
-false value when the tied hash is considered empty. If this method does
+This is called when the hash is evaluated in scalar context, and in 5.28
+onwards, by C<keys> in boolean context. In order to mimic the behaviour of
+untied hashes, this method must return a value which when used as boolean,
+indicates whether the tied hash is considered empty. If this method does
 not exist, perl will make some educated guesses and return true when
 the hash is inside an iteration. If this isn't the case, FIRSTKEY is
 called, and the result will be a false value if FIRSTKEY returns the empty
diff --git a/sv.h b/sv.h
index 198d1d1d3c..a31bd73a52 100644
--- a/sv.h
+++ b/sv.h
@@ -1775,7 +1775,7 @@ Like C<sv_utf8_upgrade>, but doesn't do magic on C<sv>.
     : SvPOK(sv)                                                \
        ? SvPVXtrue(sv)                                 \
     : SvIOK(sv)                                                \
-        ? (SvIVX(sv) != 0)                              \
+        ? (SvIVX(sv) != 0 /* cast to bool */)           \
     : (SvROK(sv) && !(   SvOBJECT(SvRV(sv))             \
                       && HvAMAGIC(SvSTASH(SvRV(sv)))))  \
         ? TRUE                                          \

--
Perl5 Master Repository

Reply via email to