develooper Front page | perl.perl5.porters | Postings from May 2004

perl-5.8.4 and /??{...}/ blocks, Inline-0.44

Thread Next
From:
Alexey Tourbin
Date:
May 15, 2004 10:54
Subject:
perl-5.8.4 and /??{...}/ blocks, Inline-0.44
Message ID:
20040515175402.GQ8966@solemn.turbinal.org
Hi,
And thanks for perl-5.8.4.

I've got a problem with Inline-0.44, which got a bit broken with
perl-5.8.4 because of /??{...}/ related changes. 

$ perl5.8.4 -c Inline-0.44/C/lib/Inline/C/ParseRegExp.pm-
Variable "$RE_balanced_brackets" is not imported at (re_eval 1) line 2.
Global symbol "$RE_balanced_brackets" requires explicit package name at (re_eval 1) line 2.
Compilation failed in regexp at Inline-0.44/C/lib/Inline/C/ParseRegExp.pm- line 25.
$ perl5.8.4 -c Inline-0.44/C/lib/Inline/C/ParseRegExp.pm
Inline-0.44/C/lib/Inline/C/ParseRegExp.pm syntax OK
$

So the following patch seems to solve the problem.

--- Inline-0.44/C/lib/Inline/C/ParseRegExp.pm-	2002-11-04 21:39:52 +0000
+++ Inline-0.44/C/lib/Inline/C/ParseRegExp.pm	2004-05-15 17:14:19 +0000
@@ -21,9 +21,9 @@ sub code {
     my $RE_comment_Cpp = q{(?:\/\*(?:(?!\*\/)[\s\S])*\*\/|\/\/[^\n]*\n)};
     my $RE_quoted      = (q{(?:(?:\")(?:[^\\\"]*(?:\\.[^\\\"]*)*)(?:\")}
                          .q{|(?:\')(?:[^\\\']*(?:\\.[^\\\']*)*)(?:\'))});
-    our $RE_balanced_brackets =
+    our $RE_balanced_brackets; $RE_balanced_brackets =
         qr'(?:[{]((?:(?>[^{}]+)|(??{$RE_balanced_brackets}))*)[}])';
-    our $RE_balanced_parens   =
+    our $RE_balanced_parens; $RE_balanced_parens =
         qr'(?:[(]((?:(?>[^()]+)|(??{$RE_balanced_parens}))*)[)])';
 
     # First, we crush out anything potentially confusing.
End of patch

Things are a bit unclear to me, though.  perl584delta(1) says:

          my $x = qr{ ... (??{ $x }) ... };

       will now (correctly) fail under use strict. (As the inner $x is and has
       always referred to $::x)

And according to perlfunc(1), $::x is always equivalent to $main::x.
On the other hand, `our $x' declaration is known to create lexically
scoped alias to the global variable $x in the current package.

So, back to Inline-0.44,
`our $RE_balanced_brackets' refers to $Inline::C::ParseRegExp::RE_balanced_brackets,
/??{$RE_balanced_brackets}/ refers to $main::RE_balanced_brackets.

So does this patch really fixes anything?
Why does syntax check pass then?
Did I get something wrong?

-- 
Alexey Tourbin
ALT Linux Team

Thread Next


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