At 09:27 -0500 1/16/04, Dan Sugalski wrote:
To some extent, yes. I just had a really nasty thought, and I think the compiler writers need to get Official Rulings on behavior.

With perl, for example, it's distinctly possible that this:

  our $foo; # It's a global
  $foo = 12;
  if ($foo > 10) {
    print $foo;
  }

will require fetching $foo's PMC out of the global namespace three times, once for each usage. I don't know offhand if this is how perl 5 works (I think it might be) and we should check for perl 6, python, and ruby. This is mainly because of the possibility of tied or overridden namespaces, which would argue for a refetch on each use.

*Not* refetching is a perfectly valid thing, and not specifying is also perfectly valid, but we need to check.

sub Foo::TIESCALAR { bless \$_[1],$_[0] } sub Foo::FETCH { warn "FETCH\n"; ${$_[0]} } sub Foo::STORE { warn "STORE\n"; ${$_[0]} = $_[1] }

our $foo; # It's a global
tie $foo,'Foo',$foo:;

$foo = 12;
if ($foo > 10) {
    print $foo;
}

__END__
STORE
FETCH
FETCH
12


Don't know why you thgink it would be fetched 3 times, but as using tied variables in Perl 5, a fetch is done _everytime_ the value of the tied variable is needed.



Liz

Reply via email to