Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Welcome to the Monastery
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Using only closures you can build an OO system, with what looks like an OO syntax. I believe that Smalltalk's OO system works like this. Definitely Lisp's CLOS does.

I'm not so sure that I'd say that CLOS needs to use closures to quite the extent you imply. Take a look for example at the Closette implementation found in The Art of the Metaobject Protocol. I think it's an exaggeration to say that this uses only (or even primarily) closures to do its work.

Update

In reply to tilly's update :-) (Let me first qualify that IANALI - I am not a Lisp implementor - take me with the appropriate grain of salt.) Certainly it's possible to do the same thing with closures. And I cheated a little bit - the Closette implementation is a simple one that has a few problems which AMOP suggests are probably overcome using closures. But I'd be surprised if any widely used CLOS implementation is largely in terms of closures - I'd expect it to be more the melange of imperative, OO, and functional programming that is Common Lisp (and that is evidenced in Closette). It wouldn't surprise me, though, if some of the Scheme object systems out there were a little more functional, and if anyone around here knows, it'd be interesting to know how its done in OCaml, which is a much more functional language than CL.


In reply to Re: Re (tilly) 2: Why Closures? by hding
in thread Why Closures? by mothra

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (4)
    As of 2014-04-19 21:17 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (483 votes), past polls