Lexical pad, not namespace.

If by "shouldn't work" you mean, "it surprises me that it does work",
that's one thing, but of course it *should* work that way because
that's how the language is defined. It isn't a design oversight.
That's how you implement static variables, for example.

Of if you mean "the following is bad style:

  use strict;
  my(five hundred variables here);

  sub uses_lexicals_as_if_they_were_globas {
      # ...
  }
  sub also_partakes {
      # ...
  }

" then sure, most people would agree with you.

On Fri, Mar 6, 2009 at 6:47 PM, sawyer x <[email protected]> wrote:
> Bad choice of words. I confused it with calling a subroutine with &,
> such as &print_name().
> The problem with putting the subroutines at the end is that it makes
> the previous variables in the code apparent to that subroutine. It's
> not lexically correct and provides an unclean environment for the
> subroutine.
>
> my $name = 'sawyer';
>
> sub print_name {
>    # this shouldn't work because the subroutine
>    # is a different namespace, but it does
>    # because the subroutine sees all the previous
>    # variables and the namespace isn't clean
>    print "$name\n";
> }
>
> On Fri, Mar 6, 2009 at 6:27 PM, Yitzchak Scott-Thoennes
> <[email protected]> wrote:
>>
>> On Fri, March 6, 2009 8:18 am, sawyer x wrote:
>> > Beyond that, you're defining the subroutine at the end, which exposes
>> > it to @_.
>>
>> What do you mean by that?
>>
>> _______________________________________________
>> Perl mailing list
>> [email protected]
>> http://perl.org.il/mailman/listinfo/perl
> _______________________________________________
> Perl mailing list
> [email protected]
> http://perl.org.il/mailman/listinfo/perl
>



-- 
Gaal Yahas <[email protected]>
http://gaal.livejournal.com/
_______________________________________________
Perl mailing list
[email protected]
http://perl.org.il/mailman/listinfo/perl

Reply via email to