diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-24 17:32:20 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 1999-05-24 17:32:20 +0000 |
commit | 14218588221b08417dacfb8f157681c6b381b73f (patch) | |
tree | 56817d24552ce5a29fc77965ab137d11b73fc29a /pod/perlobj.pod | |
parent | 9263d47b7ba3c92b743ac884edfaa80847325f4d (diff) | |
download | perl-14218588221b08417dacfb8f157681c6b381b73f.tar.gz |
more pod updates from Tom Christiansen; regen perltoc
p4raw-id: //depot/perl@3462
Diffstat (limited to 'pod/perlobj.pod')
-rw-r--r-- | pod/perlobj.pod | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/pod/perlobj.pod b/pod/perlobj.pod index 137896f1da..21073a795a 100644 --- a/pod/perlobj.pod +++ b/pod/perlobj.pod @@ -4,7 +4,7 @@ perlobj - Perl objects =head1 DESCRIPTION -First of all, you need to understand what references are in Perl. +First you need to understand what references are in Perl. See L<perlref> for that. Second, if you still find the following reference work too complicated, a tutorial on object-oriented programming in Perl can be found in L<perltoot> and L<perltootc>. @@ -50,7 +50,7 @@ a construct this way, too: package Critter; sub spawn { bless {} } -In fact, this might even be preferable, because the C++ programmers won't +This might even be preferable, because the C++ programmers won't be tricked into thinking that C<new> works in Perl as it does in C++. It doesn't. We recommend that you name your constructors whatever makes sense in the context of the problem you're solving. For example, @@ -73,7 +73,7 @@ have been returned directly, like this: return $self; } -In fact, you often see such a thing in more complicated constructors +You often see such a thing in more complicated constructors that wish to call methods in the class as part of the construction: sub new { @@ -115,7 +115,7 @@ reference as an ordinary reference. Outside the class package, the reference is generally treated as an opaque value that may be accessed only through the class's methods. -Although a a constructor can in theory re-bless a referenced object +Although a constructor can in theory re-bless a referenced object currently belonging to another class, this is almost certainly going to get you into trouble. The new class is responsible for all cleanup later. The previous blessing is forgotten, as an object @@ -155,7 +155,7 @@ last base class. Several commonly used methods are automatically supplied in the UNIVERSAL class; see L<"Default UNIVERSAL methods"> for more details. -If a missing method is found in one of the base classes, it is cached +If a missing method is found in a base class, it is cached in the current class for efficiency. Changing @ISA or defining new subroutines invalidates the cache and causes Perl to do the lookup again. @@ -285,13 +285,13 @@ For more reasons why the indirect object syntax is ambiguous, see L<"WARNING"> below. There are times when you wish to specify which class's method to use. -In this case, you can call your method as an ordinary subroutine +Here you can call your method as an ordinary subroutine call, being sure to pass the requisite first argument explicitly: $fred = MyCritter::find("Critter", "Fred"); MyCritter::display($fred, 'Height', 'Weight'); -Note however, that this does not do any inheritance. If you wish +Unlike method calls, function calls don't consider inheritance. If you wish merely to specify that Perl should I<START> looking for a method in a particular package, use an ordinary method call, but qualify the method name with the package like this: @@ -360,7 +360,7 @@ function in scope. You'd end up calling the current package's C<new> as a subroutine, rather than the desired class's method. The compiler tries to cheat by remembering bareword C<require>s, but the grief if it messes up just isn't worth the years of debugging it would likely take -you to to track such subtle bugs down. +you to track such subtle bugs down. The infix arrow notation using ``C<-E<gt>>'' doesn't suffer from either of these disturbing ambiguities, so we recommend you use it exclusively. @@ -411,7 +411,7 @@ C<isa> uses a very similar method and cache-ing strategy. This may cause strange effects if the Perl code dynamically changes @ISA in any package. You may add other methods to the UNIVERSAL class via Perl or XS code. -You do not need to C<use UNIVERSAL> in order to make these methods +You do not need to C<use UNIVERSAL> to make these methods available to your program. This is necessary only if you wish to have C<isa> available as a plain subroutine in the current package. @@ -436,7 +436,7 @@ object destruction, or for ensuring that destructors in the base classes of your choosing get called. Explicitly calling DESTROY is also possible, but is usually never needed. -Do not confuse the foregoing with how objects I<CONTAINED> in the current +Do not confuse the previous discussion with how objects I<CONTAINED> in the current one are destroyed. Such objects will be freed and destroyed automatically when the current object is freed, provided no other references to them exist elsewhere. @@ -449,8 +449,8 @@ with it for the next six months or so. =head2 Two-Phased Garbage Collection -For most purposes, Perl uses a fast and simple reference-based -garbage collection system. For this reason, there's an extra +For most purposes, Perl uses a fast and simple, reference-based +garbage collection system. That means there's an extra dereference going on at some level, so if you haven't built your Perl executable using your C compiler's C<-O> flag, performance will suffer. If you I<have> built Perl with C<cc -O>, then this @@ -535,8 +535,8 @@ When run as F</tmp/test>, the following output is produced: Notice that "global destruction" bit there? That's the thread garbage collector reaching the unreachable. -Objects are always destructed, even when regular refs aren't and in fact -are destructed in a separate pass before ordinary refs just to try to +Objects are always destructed, even when regular refs aren't. Objects +are destructed in a separate pass before ordinary refs just to prevent object destructors from using refs that have been themselves destructed. Plain refs are only garbage-collected if the destruct level is greater than 0. You can test the higher levels of global destruction |