>> >perl5 formats do NOT support lexicals
>> 
>> Eh? It looks like it, though.
>> 
>>      my $foo;
>>      format STDOUT =
>>      @>>>>>>>
>>      $foo
>>      .
>> 
>>      $foo = 123;
>>      write;
>>      $foo = 45;
>>      write;
>> 
>> It looks *so much* that way, that I think you must be wrong.

>my $foo = 3;
>format STDOUT =
>@<<
>$foo
>.

>{ my $foo = 5;
>  write;
>  }
>---
>3

I do not think you two are arguing about the same thing.

Certainly as Bart has shown, formats *can* see lexicals.  Your
illustration does not disprove that.  It simply shows that lexical
scoping is static scoping, not dynamic scoping, and that the binding
of the variable to the format occurs as the format is declared, not
when a write executed.

This is exactly the same thing as occurs with closures in terms of
declaration/creation versus their execution.  All that matters is
what's in scope when the format or closure template is brought into
existence.  It doesn't matter what happens later, which would be
dynamic scoping, not static scoping.  And this is surely not
considered "not supporting lexicals".

--tom

Reply via email to