return $self;
}
-Or if you expect people to call not just C<CLASS-E<gt>new()> but also
-C<$obj-E<gt>new()>, then use something like this. The initialize()
+Or if you expect people to call not just C<< CLASS->new() >> but also
+C<< $obj->new() >>, then use something like this. The initialize()
method used will be of whatever $class we blessed the
object into:
If none of that works, Perl finally gives up and complains.
+If you want to stop the AUTOLOAD inheritance say simply
+
+ sub AUTOLOAD;
+
+and the call will die using the name of the sub being called.
+
Perl classes do method inheritance only. Data inheritance is left up
to the class itself. By and large, this is not a problem in Perl,
because most classes model the attributes of their object using an
display {find Critter "Fred"} 'Height', 'Weight';
-For C++ fans, there's also a syntax using -E<gt> notation that does exactly
+For C++ fans, there's also a syntax using -> notation that does exactly
the same thing. The parentheses are required if there are any arguments.
$fred = Critter->find("Fred");
Those actually parse as the very surprising:
$obj->move->{FIELD}; # Well, lookee here
- $ary->move->[$i]; # Didn't expect this one, eh?
+ $ary->move([$i]); # Didn't expect this one, eh?
Rather than what you might have expected:
$obj->{FIELD}->move(); # You should be so lucky.
$ary[$i]->move; # Yeah, sure.
-The left side of ``-E<gt>'' is not so limited, because it's an infix operator,
+The left side of ``->'' is not so limited, because it's an infix operator,
not a postfix operator.
As if that weren't bad enough, think about this: Perl must guess I<at
messes up just isn't worth the years of debugging it would likely take
you to track such subtle bugs down.
-The infix arrow notation using ``C<-E<gt>>'' doesn't suffer from either
+The infix arrow notation using ``C<< -> >>'' doesn't suffer from either
of these disturbing ambiguities, so we recommend you use it exclusively.
=head2 Default UNIVERSAL methods