>  Attached is a new version of the package with the patch...

This is a fantastic contribution to TT2!  Congratulations!

I have a couple of minor comments:

  - This (unusual) sequence causes a seg fault:

        [% x = [1]; x.y.z = 2; %]

    (The perl Stash.pm ignores the illegal lvalue.)

  - With Leon's patch, array indexes can be negative (eg: x.-1 is
    the same as x.last).  I like this feature and I think the perl
    Stash.pm should support it too.  Attached is a tiny patch to
    Stash.pm and Stash/Context.pm.

  - Around line 554 of Stash.xs, should "len > 1" really be "len >= 1"?
    (However, I wasn't able to create an example that showed different
    behavior to Stash.pm.)

>       } else if (len > 1 && (svp = av_fetch(array, 1, FALSE)) &&
>                   (*svp != &PL_sv_undef)) {

Regards,
Craig

--- Stash.pm.orig       Fri Jun 29 06:34:43 2001
+++ Stash.pm    Thu Aug 23 22:47:08 2001
@@ -491,7 +491,7 @@
        if (($value = $LIST_OPS->{ $item }) && ! $lvalue) {
            @result = &$value($root, @$args);               ## @result
        }
-       elsif ($item =~ /^\d+$/) {
+       elsif ($item =~ /^-?\d+$/) {
            $value = $root->[$item];
            return $value unless ref $value eq 'CODE';      ## RETURN
            @result = &$value(@$args);                      ## @result
@@ -605,7 +605,7 @@
        return ($root->{ $item } = $value)                      ## RETURN
            unless $default && $root->{ $item };
     }
-    elsif ($rootref eq 'ARRAY' && $item =~ /^\d+$/) {
+    elsif ($rootref eq 'ARRAY' && $item =~ /^-?\d+$/) {
        # or set a list item by index number
        return ($root->[$item] = $value)                        ## RETURN
            unless $default && $root->{ $item };
--- Stash/Context.pm.orig       Fri Jun 29 06:34:43 2001
+++ Stash/Context.pm    Thu Aug 23 22:49:03 2001
@@ -518,7 +518,7 @@
        unless defined($root) and defined($item) and $item !~ /^[\._]/;
 
     if (ref(\$root) eq "SCALAR" && !$lvalue &&
-            (($value = $LIST_OPS->{ $item }) || $item =~ /^\d+$/) ) {
+            (($value = $LIST_OPS->{ $item }) || $item =~ /^-?\d+$/) ) {
         #
         # Promote scalar to one element list, to be processed below.
         #
@@ -575,7 +575,7 @@
                 $root->[$i] = &$value($root->[$i], @$args); ## @result
             }
        }
-       elsif ($item =~ /^\d+$/) {
+       elsif ($item =~ /^-?\d+$/) {
            $value = $root->[$item];
             ($ret, $retVal, @result) = _dotop_return($value, $args, $returnRef,
                                                      $scalarContext);
@@ -720,7 +720,7 @@
        return ($root->{ $item } = $value)                      ## RETURN
            unless $default && $root->{ $item };
     }
-    elsif ($rootref eq 'ARRAY' && $item =~ /^\d+$/) {
+    elsif ($rootref eq 'ARRAY' && $item =~ /^-?\d+$/) {
        # or set a list item by index number
        return ($root->[$item] = $value)                        ## RETURN
            unless $default && $root->{ $item };


Reply via email to