Refresh description of sprintf()
[p5sagit/p5-mst-13.2.git] / pod / perltoot.pod
index c235912..0c5b418 100644 (file)
@@ -1467,12 +1467,12 @@ as detailed above.
 Perl programmers have responded to this by creating several different
 class construction classes.  These metaclasses are classes
 that create other classes.  A couple worth looking at are
-Class::Template and Alias.  These and other related metaclasses can be
+Class::Struct and Alias.  These and other related metaclasses can be
 found in the modules directory on CPAN.
 
-=head2 Class::Template
+=head2 Class::Struct
 
-One of the older ones is Class::Template.  In fact, its syntax and
+One of the older ones is Class::Struct.  In fact, its syntax and
 interface were sketched out long before perl5 even solidified into a
 real thing.  What it does is provide you a way to "declare" a class
 as having objects whose fields are of a specific type.  The function
@@ -1481,11 +1481,11 @@ structures or records are not base types in Perl, each time you want to
 create a class to provide a record-like data object, you yourself have
 to define a new() method, plus separate data-access methods for each of
 that record's fields.  You'll quickly become bored with this process.
-The Class::Template::struct() function alleviates this tedium.
+The Class::Struct::struct() function alleviates this tedium.
 
 Here's a simple example of using it:
 
-    use Class::Template qw(struct);
+    use Class::Struct qw(struct);
     use Jobbie;  # user-defined; see below
 
     struct 'Fred' => {
@@ -1520,7 +1520,7 @@ act like structs in the C sense.
     printf "perl.com's real name is %s, address %s\n",
        $h->name, inet_ntoa($h->addr);
 
-Here's how to do this using the Class::Template module.
+Here's how to do this using the Class::Struct module.
 The crux is going to be this call:
 
     struct 'Net::hostent' => [         # note bracket
@@ -1544,7 +1544,7 @@ We could also have implemented our object this way:
        addr_list  => '@',
      };
 
-and then Class::Template would have used an anonymous hash as the object
+and then Class::Struct would have used an anonymous hash as the object
 type, instead of an anonymous array.  The array is faster and smaller,
 but the hash works out better if you eventually want to do inheritance.
 Since for this struct-like object we aren't planning on inheritance,
@@ -1557,8 +1557,7 @@ Here's the whole implementation:
 
     BEGIN {
        use Exporter   ();
-       use vars       qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-       @ISA         = qw(Exporter);
+       use vars       qw(@EXPORT @EXPORT_OK %EXPORT_TAGS);
        @EXPORT      = qw(gethostbyname gethostbyaddr gethost);
        @EXPORT_OK   = qw(
                           $h_name         @h_aliases
@@ -1569,7 +1568,10 @@ Here's the whole implementation:
     }
     use vars      @EXPORT_OK;
 
-    use Class::Template qw(struct);
+    # Class::Struct forbids use of @ISA
+    sub import { goto &Exporter::import }
+
+    use Class::Struct qw(struct);
     struct 'Net::hostent' => [
        name        => '$',
        aliases     => '@',
@@ -1582,7 +1584,7 @@ Here's the whole implementation:
 
     sub populate (@) {
        return unless @_;
-       my $hob = new();  # Class::Template made this!
+       my $hob = new();  # Class::Struct made this!
        $h_name     =    $hob->[0]              = $_[0];
        @h_aliases  = @{ $hob->[1] } = split ' ', $_[1];
        $h_addrtype =    $hob->[2]              = $_[2];
@@ -1615,9 +1617,10 @@ Here's the whole implementation:
 
 We've snuck in quite a fair bit of other concepts besides just dynamic
 class creation, like overriding core functions, import/export bits,
-function prototyping, and short-cut function call via C<&whatever>.
-These all mostly make sense from the perspective of a traditional module,
-but as you can see, we can also use them in an object module.
+function prototyping, short-cut function call via C<&whatever>, and
+function replacement with C<goto &whatever>.  These all mostly make
+sense from the perspective of a traditional module, but as you can see,
+we can also use them in an object module.
 
 You can look at other object-based, struct-like overrides of core
 functions in the 5.004 release of Perl in File::stat, Net::hostent,
@@ -1695,7 +1698,7 @@ they're still considered global variables with temporary values, just
 as with any other local().
 
 It would be nice to combine Alias with
-something like Class::Template or Class::MethodMaker.
+something like Class::Struct or Class::MethodMaker.
 
 =head2 NOTES