in reply to Re: What does "my Foo $bar" do?
in thread What does "my Foo $bar" do?

I have a hard time believing it is a NOP. I actually first saw it right at the top of the synopsis section of the fields doc:

[snip] package Foo; use fields qw(foo bar _Foo_private); sub new { my Foo $self = shift; [snip]

As for the attributes example, the attributes doc claims the example is syntactically valid. I realize it is not supposed to "do" anything (other than, I would hope, compile); I'm just trying to grok attributes and fields and ran into these stumbling blocks.

Brad

Replies are listed 'Best First'.
Re^3: What does "my Foo $bar" do?
by PodMaster (Abbot) on Aug 08, 2004 at 09:53 UTC
    Does this convince you?
    C:\>perl -MO=Concise,-ascii -e"package Foo;my $bar = 23;" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(Foo 1 -e:1) v ->3 5 <2> sassign vKS/2 ->6 3 <$> const[IV 23] s ->4 4 <0> padsv[$bar:1,2] sRM*/LVINTRO ->5 -e syntax OK C:\>perl -MO=Concise,-ascii -e"package Foo;my Foo $bar = 23;" 6 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(Foo 1 -e:1) v ->3 5 <2> sassign vKS/2 ->6 3 <$> const[IV 23] s ->4 4 <0> padsv[$bar:1,2] sRM*/LVINTRO ->5 -e syntax OK
    Looks pretty convincing to me (there is no difference between the op trees, thus it is a null op).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re^3: What does "my Foo $bar" do?
by tachyon (Chancellor) on Aug 08, 2004 at 09:53 UTC

    I have a hard time believing it is a NOP

    It is syntactically valid because it compiles. QED. It apparently does nothing accoridng to Deparse. QED also is it not? This is also valid syntax, left over from previous perls.....

    C:\>perl -MO=Deparse -e"package Foo; $Foo'bar=42" package Foo; $bar = 42; -e syntax OK C:\>

    cheers

    tachyon