Nah, it's a hack. Useful, but still a hack. Why?
- Before even using objects (in the bless sense), a Perl programmer already has to understand references, packages, and complex datastructures. Java programmers create their first object when they write a "Hello, World!"
- Lack of a good way of doing protected methods/attributes (many people think that doing private data can't be done, but it's do-able using lexicals declared at the top of the package)
- No subroutine prototypes (well, no useful subroutine prototypes, especially in terms of objects)
- No compile-time checking of method lookups, which consequently makes it:
- Slow
- Unable to inline constant methods
- Impossible for use strict 'subs'; to help you
- Generally makes it easy to do objects wrong
---- I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
: () { :|:& };:
Note: All code is untested, unless otherwise stated
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
|
|