Perl 5.18.0 is now available
21–30 of 69 posts
Re: Perl 5.18.0 is now available
#22The dynamic scoping in Perl seems a bit troublesome to me. Maybe even a security issue. Can you prevent functions you call from accessing variables in your scope? Do you have to somehow sanitize your scope if this is an issue? Seems a little bit worrying. With the exception of closures inside nested functions, I wish functions just had their own scope and if you want them to have anything else, just pass it in.
Re: Perl 5.18.0 is now available
#23Earlier quoted context omitted.
I think there should be some kind of changing of names. For a while it looked like it's another incremental step, if a big one. Which obviously requires running two implementations in parallel for a while -- similar to Python 2 and 3, or several operating systems and distros. But right now, especially once Perl development really picked up, it might be time to "divorce" the two languages. It seems more like Algol60 v…
Perl5 users won't switch to Perl6 because they're working on Perl5 code and don't want to change their habits. Non-Perl devs won't switch to Perl6 because the P word scares them. So, yes, changing the name might be a good idea. And making an enjoyable web-based tutorial.
Re: Perl 5.18.0 is now available
#24Earlier quoted context omitted.
I think there should be some kind of changing of names. For a while it looked like it's another incremental step, if a big one. Which obviously requires running two implementations in parallel for a while -- similar to Python 2 and 3, or several operating systems and distros. But right now, especially once Perl development really picked up, it might be time to "divorce" the two languages. It seems more like Algol60 v…
Perl5 users won't switch to Perl6 because they're working on Perl5 code and don't want to change their habits. Non-Perl devs won't switch to Perl6 because the P word scares them. So, yes, changing the name might be a good idea. And making an enjoyable web-based tutorial.
Re: Perl 5.18.0 is now available
#25The dynamic scoping in Perl seems a bit troublesome to me. Maybe even a security issue. Can you prevent functions you call from accessing variables in your scope? Do you have to somehow sanitize your scope if this is an issue? Seems a little bit worrying. With the exception of closures inside nested functions, I wish functions just had their own scope and if you want them to have anything else, just pass it in.
This has been standard advice since the last millennium. But you can't change it without breaking backwards compatibility.
That said, I do have several good uses for local. But not normal ones. My favorite is to use local to dynamically scope entries in a hash. I wind up using this every year or two to put in an automatic check to catch infinite recursion.
Re: Perl 5.18.0 is now available
#26The dynamic scoping in Perl seems a bit troublesome to me. Maybe even a security issue. Can you prevent functions you call from accessing variables in your scope? Do you have to somehow sanitize your scope if this is an issue? Seems a little bit worrying. With the exception of closures inside nested functions, I wish functions just had their own scope and if you want them to have anything else, just pass it in.
When I first started using perl, I too, worried about this and other similar issues. But after 10+ years of using perl, I've never -- not once -- actually run into this problem in the real world.
Re: Perl 5.18.0 is now available
#27In particular, I'm lost on the difference between
sub outer {
my $closurevar;
my $inner = sub {
... use $closurevar...
};
}
and sub outer {
my $closurevar;
my sub inner {
... use $closurevar...
}
}
(I mean this as an honest question. That said, I do hope that I'm missing something and this is more than just a syntax gloss.)[1]: http://search.cpan.org/~rjbs/perl-5.18.0/pod/perlsub.pod#Lex...
Re: Perl 5.18.0 is now available
#28Can someone explain the point of the lexical subroutines? [1] In particular, I'm lost on the difference between sub outer { my $closurevar; my $inner = sub { ... use $closurevar... }; } and sub outer { my $closurevar; my sub inner { ... use $closurevar... } } (I mean this as an honest question. That said, I do hope that I'm missing something and this is more than just a syntax gloss.) [1]: http://search.cpan.org/~rjb…
Oh, and I guess lexical subs can have prototypes, which were ignored when calling a coderef with `&` or `->()`. This allows to create really nice, but properly scoped pseudosyntax.
Re: Perl 5.18.0 is now available
#29Can someone explain the point of the lexical subroutines? [1] In particular, I'm lost on the difference between sub outer { my $closurevar; my $inner = sub { ... use $closurevar... }; } and sub outer { my $closurevar; my sub inner { ... use $closurevar... } } (I mean this as an honest question. That said, I do hope that I'm missing something and this is more than just a syntax gloss.) [1]: http://search.cpan.org/~rjb…
Re: Perl 5.18.0 is now available
#30Can someone explain the point of the lexical subroutines? [1] In particular, I'm lost on the difference between sub outer { my $closurevar; my $inner = sub { ... use $closurevar... }; } and sub outer { my $closurevar; my sub inner { ... use $closurevar... } } (I mean this as an honest question. That said, I do hope that I'm missing something and this is more than just a syntax gloss.) [1]: http://search.cpan.org/~rjb…
In the end, everything is syntax. In the first solution, the inner sub would be called as "$inner->()" or "&$inner()". With lexical subs, we get the much nicer syntax "inner()". This decreases the syntactic pain when structuring your code to use nested functions, thus encouraging good design. Oh, and I guess lexical subs can have prototypes, which were ignored when calling a coderef with `&` or `->()`. This allows to…
use 5.018;
no warnings "experimental::lexical_subs";
use feature "lexical_subs";
Don't use perl experimental features. Not portable. Not well thought.May break horribly.
"state sub creates a subroutine visible within the lexical scope in which it is declared. The subroutine is shared between calls to the outer sub."
So you should be using "state sub"
Or use python which has non-experimental "inner functions"