In perl.git, the branch smartmatch has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/d0b243e39ca09d7da156b4027255b58fa0a84810?hp=6d743019f3ff1c2efcf74a1e4f98ea5bd3b7351a>

- Log -----------------------------------------------------------------
commit d0b243e39ca09d7da156b4027255b58fa0a84810
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Fri May 8 23:01:18 2009 +0200

    Document what to do with object on the left and add some TODO tests for that

M       pod/perlsyn.pod
M       t/op/smartmatch.t

commit 365c4e3d7660763689bc62ead0a9a495a26bcad7
Author: Rafael Garcia-Suarez <[email protected]>
Date:   Fri May 8 22:40:09 2009 +0200

    Inline macros used only once

M       pp_ctl.c
-----------------------------------------------------------------------

Summary of changes:
 pod/perlsyn.pod   |    5 +++--
 pp_ctl.c          |   12 ++++--------
 t/op/smartmatch.t |    6 ++++++
 3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/pod/perlsyn.pod b/pod/perlsyn.pod
index 9f964e0..038bcfa 100644
--- a/pod/perlsyn.pod
+++ b/pod/perlsyn.pod
@@ -687,8 +687,9 @@ The behaviour of a smart match depends on what type of 
thing its arguments
 are. The behaviour is determined by the following table: the first row
 that applies determines the match behaviour (which is thus mostly
 determined by the type of the right operand). Note that the smart match
-implicitly dereferences any hash or array ref, so the "Hash" and "Array"
-entries apply in those cases.
+implicitly dereferences any non-blessed hash or array ref, so the "Hash"
+and "Array" entries apply in those cases. (For blessed references, the
+"Any" entry apply.)
 
     $a      $b        Type of Match Implied    Matching Code
     ======  =====     =====================    =============
diff --git a/pp_ctl.c b/pp_ctl.c
index c601f7c..6a5ea65 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4000,12 +4000,6 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
     SV *e = TOPs;      /* e is for 'expression' */
     SV *d = TOPm1s;    /* d is for 'default', as in PL_defgv */
 
-#   define SM_SEEN_THIS(sv) hv_exists_ent(seen_this, \
-       sv_2mortal(newSViv(PTR2IV(sv))), 0)
-
-#   define SM_SEEN_OTHER(sv) hv_exists_ent(seen_other, \
-       sv_2mortal(newSViv(PTR2IV(sv))), 0)
-
     if (SvAMAGIC(e)) {
        SV * const tmpsv = amagic_call(d, e, smart_amg, 0);
        if (tmpsv) {
@@ -4265,8 +4259,10 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
                        if (this_elem || other_elem)
                            RETPUSHNO;
                    }
-                   else if (SM_SEEN_THIS(*this_elem)
-                        || SM_SEEN_OTHER(*other_elem))
+                   else if (hv_exists_ent(seen_this,
+                               sv_2mortal(newSViv(PTR2IV(*this_elem))), 0) ||
+                           hv_exists_ent(seen_other,
+                               sv_2mortal(newSViv(PTR2IV(*other_elem))), 0))
                    {
                        if (*this_elem != *other_elem)
                            RETPUSHNO;
diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t
index 75c0ec0..8047451 100644
--- a/t/op/smartmatch.t
+++ b/t/op/smartmatch.t
@@ -200,6 +200,8 @@ __DATA__
        qr//            \&bar
 !      [1]             \&foo
 !      {a=>1}          \&foo
+       $obj            sub { ref $_[0] =~ /NoOverload/ }       TODO
+       $ov_obj         sub { ref $_[0] =~ /CopyOverload/ }     TODO
 # empty stuff matches, because the sub is never called:
        []              \&foo
        {}              \&foo
@@ -312,6 +314,10 @@ __DATA__
 =      \...@nums                       @tied_nums
 =      @nums                   @tied_nums
 
+#  - an object
+!      $obj            @fooormore
+       $obj            [sub{ref shift}]        TODO
+
 #  - works with lists instead of arrays
        "foo"                   qw(foo bar)     TODO
        "foo"                   ('foo','bar')   TODO

--
Perl5 Master Repository

Reply via email to