This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tidy up lists of 'our' variables.
[perl5.git] / pod / perltooc.pod
index c162220..06f697c 100644 (file)
@@ -624,7 +624,7 @@ The astonishing thing about the Cosmos class above is that the value
 returned by the &bigbang "constructor" is not a reference to a blessed
 object at all.  It's just the class's own name.  A class name is, for
 virtually all intents and purposes, a perfectly acceptable object.
-It has state, behavior, and identify, the three crucial components
+It has state, behavior, and identity, the three crucial components
 of an object system.  It even manifests inheritance, polymorphism,
 and encapsulation.  And what more can you ask of an object?
 
@@ -646,7 +646,7 @@ name them whatever you care to.  Blindly and obediently using new()
 for each and every constructor you ever write is to speak Perl with
 such a severe C++ accent that you do a disservice to both languages.
 There's no reason to insist that each class have but one constructor,
-or that that constructor be named new(), or that that constructor be
+or that a constructor be named new(), or that a constructor be
 used solely as a class method and not an object method.
 
 The next section shows how useful it can be to further distance ourselves
@@ -692,7 +692,7 @@ that happens to be named &spawn.
     print $obj3->color();      # prints "vermilion"
 
 Each of these objects' colors is now "vermilion", because that's the
-meta-object's value that attribute, and these objects do not have
+meta-object's value for that attribute, and these objects do not have
 individual color values set.
 
 Changing the attribute on one object has no effect on other objects
@@ -842,7 +842,7 @@ ones.
     # invoked as class method or object method
     sub has_attribute {
        my($self, $attr)  = @_;
-       my $class = ref $self if $self;
+       my $class = ref($self) || $self;
        return exists $class->{$attr};  
     } 
 
@@ -922,7 +922,7 @@ all privacy in Perl, and it is a powerful form of privacy indeed.
 
 It is widely perceived, and indeed has often been written, that Perl
 provides no data hiding, that it affords the class designer no privacy
-nor isolation, merely a rag-tag assortment of weak and unenforcible
+nor isolation, merely a rag-tag assortment of weak and unenforceable
 social conventions instead.  This perception is demonstrably false and
 easily disproven.  In the next section, we show how to implement forms
 of privacy that are far stronger than those provided in nearly any
@@ -1089,7 +1089,10 @@ for a significant performance improvement:
        if (my $coderef = $self->can($parent . "::CData1")) {
            $self->$coderef($newvalue);
        }
-    } 
+    }
+
+If you override C<UNIVERSAL::can> in your own classes, be sure to return the
+reference appropriately.
 
 =head2 Locking the Door and Throwing Away the Key
 
@@ -1106,7 +1109,7 @@ itself access its own class attributes without the mediating intervention of
 properly designed accessor methods is probably not a good idea after all.
 
 Restricting access to class attributes from the class itself is usually
-not enforcible even in strongly object-oriented languages.  But in Perl,
+not enforceable even in strongly object-oriented languages.  But in Perl,
 you can.
 
 Here's one way:
@@ -1294,15 +1297,11 @@ Inheritance is a powerful but subtle device, best used only after careful
 forethought and design.  Aggregation instead of inheritance is often a
 better approach.
 
-We use the hypothetical our() syntax for package variables.  It works
-like C<use vars>, but looks like my().  It should be in this summer's
-major release (5.6) of perl--we hope.
-
 You can't use file-scoped lexicals in conjunction with the SelfLoader
 or the AutoLoader, because they alter the lexical scope in which the
 module's methods wind up getting compiled.
 
-The usual mealy-mouthed package-mungeing doubtless applies to setting
+The usual mealy-mouthed package-munging doubtless applies to setting
 up names of object attributes.  For example, C<< $self->{ObData1} >>
 should probably be C<< $self->{ __PACKAGE__ . "_ObData1" } >>, but that
 would just confuse the examples.