In Perl it's trivial to make an anonymous sub a named one and vice versa. So what?

And I think the example I showed proves my point, that the var from the outer scope is bound to the sub.

> In the context of Perl, perlglossary does say that a closure is "An anonymous subroutine that,

One of my biggest problems with the perldocs is that it's a collection² from different authors and sources.

I like to quote perlglossary myself, because it's from Larry himself. But it's from the appendix of one of his books. And he sometimes values easy wording with puns over being consistent. (update: phrase reworded)

But the implementation of lexical closures is the same for all subs.

I envy other languages which have a more formal approach to language definition. The ECMA process dragged JS out of the mud. And those PEP discussions in Python look³ decent.

AFAIK was closure invented in the context of Lisp, hence well° defined there.

updates

°) another extreme is PHP where "closure" always means (meant?) "anonymous sub", no matter if there are any vars involved. (I think they fixed the docs in the meantime, but this should prove my point that docs can't always reinvent fixed terminology)

²) inconsistent

³) "at least look" (I can only judge by the optics here)

Cheers Rolf
(addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
Wikisyntax for the Monastery


In reply to Re^10: Unclear about 'our' (updated) by LanX
in thread Unclear about 'our' by ibm1620

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.