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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|