Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
> I was also quite happily solving my programming problems in languages that don't support them for 15+ years before I became acquainted with them.

I agree and as I said closures are somehow the other side of the OO coin in allowing encapsulated variables.

Just more elegantly done with less code in most languages.

It's like saying why do we need lexical variables, as long as we care about chosing the right package-namespaces we can achieve the same. True, but most of us don't wanna code Perl4 anymore!

> I've been reading a lot about constructing interpreters and VMs lately, and one thing that seems common to most new ones is the seemingly obligatory inclusion of closures;

I think it's also part of the feature competition. Like "What you have no App to shave your legs on your new smartphone"?

OTOH what I really like about JS is that it does FP (almost¹) excatly like Perl, while Ruby and Python suck at closure side-effects.

IMHO it's far easier to port FP-patterns than OO-patterns, and closures are indispensable for it.²

Saying this you might have noticed that some participants in this thread didn't really know what closure.

So yes you, can be a very efficient programmer w/o closures.

Cheers Rolf

¹) well exactly if you have a dialect allowing to swap var with let.

²) And we have this "one package per file" paradigm, which forbids to just add another encapsulation on the fly. (No fun discussing the perl critic addicts)

IIRC correctly there was a nice thread where GrandFather solved a problem with an embedded mini-class where I used closures... If I can find it, I'll update.

In reply to Re^5: Real life uses for closures. (update: disambiguation) by LanX
in thread Real life uses for closures. by BrowserUk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the daffodils sway...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2018-04-21 10:32 GMT
    Find Nodes?
      Voting Booth?