Well done, but you have omitted the fact that
dereferencing an anonymous function means calling it:
&$aSub(@args);
$aSub->(@args); # This notation due to merlyn
and at this point if people wonder why a method call
looks like a dereferencing operation, they should give
themselves brownie points because it is. When you call
bless on a reference, it is not the reference that is
blessed, it is the thing that the reference points at.
And a method call is really a matter of dereferencing the
reference in a way that is looking for a method. Consider:
package foo;
sub bar {
print "foobar strikes again!\n";
}
package main;
# Create and throw away an object
bless \$x, "foo";
# But the blessing is not forgotten!
(\$x)->bar();
This detail was pointed out to me by merlyn in chatter
about a week ago. At first it surprised me, but then I
thought about it and it made a lot of sense. After all
if I have 10 references to the same thing, shouldn't
dereferencing any of them be equivalent? Doesn't a
method call look like just dereferencing...?
And so to your list you can add calling an anonymous
subroutine and making a method call as dereferencing
operations.
-
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.
|