in reply to Re: my $x = <expr>; vs my $x; $x = <expr>;
in thread my $x = <expr>; vs my $x; $x = <expr>;

It's not a bug, it's an accidental feature, and it only happens when the condition is false. It's because the dual nature of my, which has effects both at compile time and at runtime.

Makeshifts last the longest.

  • Comment on Re^2: my $x = <expr>; vs my $x; $x = <expr>;

Replies are listed 'Best First'.
Re^3: my $x = <expr>; vs my $x; $x = <expr>;
by dave_the_m (Monsignor) on Jun 05, 2004 at 21:41 UTC
    It's not a bug, it's an accidental feature
    Well, that's a matter of semantics:-) In 5.10.0 the form my $x if 0 will be officially deprecated, and will give a warning (and I should know - I added the warning!). It was felt that benefits of the "feature" for eg pseudo-static variables was outweighed by the unexpectedness of its behavour for most people.

    Dave.

      Per an email from Larry Wall, he calls it an "accident of implementation." It also has different behavior in differing versions, so I'm glad to see the warning being added. Though I'm not yet won over to the perl6 way of thinking about variable traits.

      --
      [ e d @ h a l l e y . c c ]