develooper Front page | perl.perl5.porters | Postings from October 2003

RE: [perl #24250] "return" required in some anonymous closures

Thread Previous | Thread Next
From:
Orton, Yves
Date:
October 20, 2003 05:59
Subject:
RE: [perl #24250] "return" required in some anonymous closures
Message ID:
71B318898201D311845C0008C75DAD1C08961318@defra1ex2
> At 13:34 +0100 10/20/03, Nick Ing-Simmons wrote:
> >  >so this looks like an optimizer problem to me: the $get sub is
> >  >referring to something else than the package lexical $foo.
> >What is a 'package lexical' ?
> >   - things are either in package or lexical never both...
> 
> A package lexical is a lexical defined at the package "scope"?

Except that there is no such thing as package scope. There is file scope and
block scope, nothing else.

#!perl -l
package foo;
my $bar="hello";
print $bar;
package main;
print $bar;

__END__
hello
hello
 
> package Foo;
> my $package_lexical;
> {
>   my $not_a_package_lexical;
> }
> 
> 
> I thought that was a pretty well known concept?

Well, I think its a pretty well known misnomer. But it still is a misnomer.
$package_lexical should actually be called $file_lexical.

If you want a "package lexical" youll have to wrap the whole thing in a
block.

package foo;
{
  my $package_foo_lexical;
}

or 

{
  package foo;
  my $package_foo_lexical;
}

Personally I like the first one more....

Yves

Thread Previous | 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