Michael G Schwern wrote:
> Go ahead and use isa() to check the class of the version object.  Can't hurt.

...said the man who wasn't working on the patch. ;-)

OK, here's my compromise:  we still use ref for the first pass through (so it
will handle the base version objects), and we try real hard to use isa() safely
if that fails.  Here's that block of the diff:

@@ -120,8 +121,8 @@
         }

         my @sigs   = ref $sig ? @$sig : $sig;
-        my $given = lc ref $val;
-        unless( grep $given eq $_, @sigs ) {
+        my $given  = ref $val;
+        unless( grep { $given eq $_ || ($_ && eval{$val->isa($_)}) } @sigs ) {
             my $takes = join " or ", map { $_ ne '' ? "$_ reference"
                                                     : "string/number"
                                          } @sigs;

I'm going to write a test that exercises this code, but I already confirmed that
a subclass of version will fail the first || term and pass the second.  Now that
I look at it again, I'd like to rewrite that grep block to be

        { $_ && ($given eq $_ || eval{$val->isa($_)) }

which is (to my mind) a little clearer about the intent of the tests.  Of course
I personally would also edit the next line to eliminate the useless "ne ''"
(which isn't clearer to my eyes).

Does this work for you?

John

-- 
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4501 Forbes Blvd
Suite H
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747

Reply via email to