It's not like providing (allowing & supporting) "lexically-scoped" subroutines should be so considered so radical...
It's not radical, and it's been discussed on and off by the perl implementors for years, and generally (I think) thought of as a good idea, but it just hasn't been done, probably because it's not considered to be worth the time, especially since you can already use lexically scoped anonymous subs for all situations you'd use lexical named subs, with only minor extra syntax, and you can assign closures to globs to redefine global subs, and neither require excessive amounts of code (one additional my statement + one deref per call, and one assignment, respectively). In the mean time, named subroutines in perl are global, and bitching about it isn't going to help.

I don't see that requiring the extra syntax of making the subroutine 'anonymous', and storing it in a variable, then calling it through a variable could possibly make its more clear for someone reading the code.
It does make it very clear you're calling a lexically scoped subroutine, instead of a global one. Not a big advantage, though, I grant you, but perl will never be Scheme. Perl isn't pretty in some ways, but it does provide (sometimes clunky, but reasonable) ways to use almost any programming technique you want (with the exceptions of macros, which are just too clunky in perl - see source filters - to be truly useful, and good multi-processor/multi-node support, which still seems to be in its infancy as far as programming languages I know go - though Erlang seems to be a good step).


In reply to Re^5: Perl scoping not logical...? by Joost
in thread Perl scoping not logical...? by perl-diddler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.