Penguin

Differences between current version and predecessor to the previous major change of perltootc(1).

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 2 Last edited on Monday, June 3, 2002 6:50:53 pm by perry
Older page: version 1 Last edited on Monday, June 3, 2002 6:50:53 pm by perry Revert
@@ -169,14 +169,14 @@
  
  
  package Some_Class; 
 use strict; 
-our %ClassData = ( # our() is new to perl5.6 
+our %! ClassData = ( # our() is new to perl5.6 
 CData1 = 
-Using closures (see perlref) and direct access to the package symbol table (see perlmod), now clone an accessor method for each key in the %ClassData hash. Each of these methods is used to fetch or store values to the specific, named class attribute. 
+Using closures (see perlref) and direct access to the package symbol table (see perlmod), now clone an accessor method for each key in the %! ClassData hash. Each of these methods is used to fetch or store values to the specific, named class attribute. 
  
  
- for my $datum (keys %ClassData) { 
+ for my $datum (keys %! ClassData) { 
 no strict 
 It's true that you could work out a solution employing an DESTROY . Such complexity is uncalled for in most cases, and certainly in this one. 
  
  
@@ -224,9 +224,9 @@
 in the package into which those methods were compiled. When 
 you invoke the 
 $Some_Class::CData1--or in the method cloning 
 version, 
-$Some_Class::ClassData{CData1}. 
+$Some_Class::! ClassData{CData1}. 
  
  
 Think of these class methods as executing in the context of 
 their base class, not in that of their derived class. 
@@ -276,9 +276,9 @@
  
 __The Eponymous Meta-Object__ 
  
  
-It could be argued that the %ClassData hash in the 
+It could be argued that the %! ClassData hash in the 
 previous example is neither the most imaginative nor the 
 most intuitive of names. Is there something else that might 
 make more sense, be more useful, or both? 
  
@@ -639,9 +639,9 @@
 # it holds all class attributes, and also all instance attributes 
 # so the latter can be used for both initialization 
 # and translucency. 
  our %Vermin = ( # our() is new to perl5.6 
-PopCount = 
+! PopCount = 
  # constructor method 
 # invoked as class method or object method 
 sub spawn { 
 my $obclass = shift; 
@@ -807,15 +807,15 @@
 to do so. 
  
  
  package Some_Class; 
-my %ClassData = ( 
+my %! ClassData = ( 
 CData1 = 
 To make this more scalable as other class attributes are added, we can again register closures into the package symbol table to create accessor methods for them. 
  
  
  package Some_Class; 
-my %ClassData = ( 
+my %! ClassData = ( 
 CData1 = 
 Requiring even your own class to use accessor methods like anybody else is probably a good thing. But demanding and expecting that everyone else, be they subclass or superclass, friend or foe, will all come to your object through mediation is more than just a good idea. It's absolutely critical to the model. Let there be in your mind no such thing as ``public'' data, nor even ``protected'' data, which is a seductive but ultimately destructive notion. Both will come back to bite at you. That's because as soon as you take that first step out of the solid position in which all state is considered completely private, save from the perspective of its own accessor methods, you have violated the envelope. And, having pierced that encapsulating envelope, you shall doubtless someday pay the price when future changes in the implementation break unrelated code. Considering that avoiding this infelicitous outcome was precisely why you consented to suffer the slings and arrows of obsequious abstraction by turning to object orientation in the first place, such breakage seems unfortunate in the extreme. 
  
  
@@ -839,9 +839,9 @@
 attributes. Since the actual method called is the one in the 
 object's derived class if this exists, you automatically get 
 per-class state this way. Any urge to provide an 
 unadvertised method to sneak out a reference to the 
-%ClassData hash should be strenuously 
+%! ClassData hash should be strenuously 
 resisted. 
  
  
 As with any other overridden method, the implementation in 
@@ -851,9 +851,9 @@
  
  
  package Another_Class; 
 @ISA = qw(Some_Class); 
- my %ClassData = ( 
+ my %! ClassData = ( 
 CData1 = 
  sub CData1 { 
 my($self, $newvalue) = @_; 
 if (@_ 
@@ -876,9 +876,9 @@
 Key__ 
  
  
 As currently implemented, any code within the same scope as 
-the file-scoped lexical %ClassData can alter that 
+the file-scoped lexical %! ClassData can alter that 
 hash directly. Is that ok? Is it acceptable or even 
 desirable to allow other parts of the implementation of this 
 class to access class attributes directly? 
  
@@ -928,11 +928,11 @@
  
  
  package Some_Class; 
  { # scope for ultra-private meta-object for class attributes 
-my %ClassData = ( 
+my %! ClassData = ( 
 CData1 = 
- for my $datum (keys %ClassData ) { 
+ for my $datum (keys %! ClassData ) { 
 no strict 
 
 The closure above can be modified to take inheritance into account using the SUPER as shown previously. 
  
@@ -995,47 +995,47 @@
  # Here's the class meta-object, eponymously named. 
 # It holds all class data, and also all instance data 
 # so the latter can be used for both initialization 
 # and translucency. it's a template. 
-my %ClassData = (  
-PopCount = 
+my %! ClassData = (  
+! PopCount = 
  # constructor method 
 # invoked as class method or object method 
 sub spawn { 
 my $obclass = shift; 
 my $class = ref($obclass) $obclass; 
 my $self = {}; 
 bless($self, $class); 
-$ClassData{PopCount}++; 
+$! ClassData{! PopCount}++; 
 # init fields from invoking object, or omit if 
 # invoking object is the class to provide translucency 
 %$self = %$obclass if ref $obclass; 
 return $self; 
 
  # translucent accessor for 
  # handle class invocation 
 unless (ref $self) { 
-$ClassData{color} = shift if @_;  
-return $ClassData{color} 
+$! ClassData{color} = shift if @_;  
+return $! ClassData{color} 
 
  # handle object invocation 
 $self- 
  # class attribute accessor for 
  # instance destructor; invoked only as object method 
 sub DESTROY { 
-$ClassData{PopCount}--; 
+$! ClassData{! PopCount}--; 
 
  # detect whether an object attribute is translucent 
 # (typically?) invoked only as object method 
 sub is_translucent { 
 my($self, $attr) = @_; 
-$self = %ClassData if !ref $self; 
+$self = %! ClassData if !ref $self; 
 return !defined $self- 
  # test for presence of attribute in class 
 # invoked as class method or object method 
 sub has_attribute { 
 my($self, $attr) = @_; 
-return exists $ClassData{$attr}; 
+return exists $! ClassData{$attr}; 
 
 !!NOTES 
  
  
@@ -1050,9 +1050,9 @@
 (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 
+! SelfLoader or the ! AutoLoader, because they alter the lexical 
 scope in which the module's methods wind up getting 
 compiled. 
  
  
@@ -1066,9 +1066,9 @@
  
 perltoot, perlobj, perlmod, and perlbot. 
  
  
-The Tie::SecureHash and Class::Data::Inheritable modules 
+The Tie::! SecureHash and Class::Data::Inheritable modules 
 from CPAN are worth checking 
 out. 
 !!AUTHOR AND COPYRIGHT 
  
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.