[perldocjp-cvs 2198] CVS update: docs/modules/base-2.14

Back to archive index
argra****@users***** argra****@users*****
2019年 11月 30日 (土) 18:25:48 JST


Date:	Saturday November 30, 2019 @ 18:25
Author:	argrath

Update of /cvsroot/perldocjp/docs/modules/base-2.14
In directory sf-cvs:/tmp/cvs-serv31289/modules/base-2.14

Added Files:
	fields.pod 
Log Message:
base-2.14/fields
===================================================================
File: fields.pod       	Status: Up-to-date

   Working revision:	1.1	Sat Nov 30 09:25:48 2019
   Repository revision:	1.1	/cvsroot/perldocjp/docs/modules/base-2.14/fields.pod,v

   Existing Tags:
	No Tags Exist

-------------- next part --------------
Index: docs/modules/base-2.14/fields.pod
diff -u /dev/null docs/modules/base-2.14/fields.pod:1.1
--- /dev/null	Sat Nov 30 18:25:48 2019
+++ docs/modules/base-2.14/fields.pod	Sat Nov 30 18:25:48 2019
@@ -0,0 +1,310 @@
+
+=encoding euc-jp
+
+=head1 NAME
+
+=begin original
+
+fields - compile-time class fields
+
+=end original
+
+fields - ¥³¥ó¥Ñ¥¤¥ë»þ¤Î¥¯¥é¥¹¥Õ¥£¡¼¥ë¥É
+
+=head1 SYNOPSIS
+
+    {
+        package Foo;
+        use fields qw(foo bar _Foo_private);
+        sub new {
+            my Foo $self = shift;
+            unless (ref $self) {
+                $self = fields::new($self);
+                $self->{_Foo_private} = "this is Foo's secret";
+            }
+            $self->{foo} = 10;
+            $self->{bar} = 20;
+            return $self;
+        }
+    }
+
+    my $var = Foo->new;
+    $var->{foo} = 42;
+
+    # this will generate an error
+    $var->{zap} = 42;
+
+    # subclassing
+    {
+        package Bar;
+        use base 'Foo';
+        use fields qw(baz _Bar_private);        # not shared with Foo
+        sub new {
+            my $class = shift;
+            my $self = fields::new($class);
+            $self->SUPER::new();                # init base fields
+            $self->{baz} = 10;                  # init own fields
+            $self->{_Bar_private} = "this is Bar's secret";
+            return $self;
+        }
+    }
+
+=head1 DESCRIPTION
+
+=begin original
+
+The C<fields> pragma enables compile-time verified class fields.
+
+=end original
+
+C<fields> ¥×¥é¥°¥Þ¤Ï¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¸¡¾Ú¤¹¤ë¥¯¥é¥¹¥Õ¥£¡¼¥ë¥É¤òÍ­¸ú¤Ë¤·¤Þ¤¹¡£
+
+=begin original
+
+NOTE: The current implementation keeps the declared fields in the %FIELDS
+hash of the calling package, but this may change in future versions.
+Do B<not> update the %FIELDS hash directly, because it must be created
+at compile-time for it to be fully useful, as is done by this pragma.
+
+=end original
+
+Ãí°Õ: ¸½ºß¤Î¼ÂÁõ¤Ï¸Æ¤Ó½Ð¤·¥Ñ¥Ã¥±¡¼¥¸¤Î %FIELDS ¥Ï¥Ã¥·¥å¤ËÀë¸À¤µ¤ì¤¿
+¥Õ¥£¡¼¥ë¥É¤òÊÝ»ý¤·¤Þ¤¹¤¬¡¢¤³¤ì¤Ï¾­Íè¤Î¥Ð¡¼¥¸¥ç¥ó¤ÇÊѹ¹¤µ¤ì¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
+%FIELDS ¥Ï¥Ã¥·¥å¤òľÀÜ B<¹¹¿·¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤>; ¤Ê¤¼¤Ê¤é¡¢¤³¤ì¤¬´°Á´¤Ë
+Í­ÍѤǤ¢¤ë¤¿¤á¤Ë¡¢¥³¥ó¥Ñ¥¤¥ë»þ¤Ë¤³¤Î¥×¥é¥°¥Þ¤¬¹Ô¤Ã¤¿¤È¤ª¤ê¤Î¤Þ¤Þ¤Ë
+ºî¤é¤ì¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¤«¤é¤Ç¤¹¡£
+
+=begin original
+
+B<Only valid for perl before 5.9.0:>
+
+=end original
+
+B<5.9.0 ¤è¤êÁ°¤Î perl ¤Ç¤Î¤ßÍ­¸ú:>
+
+=begin original
+
+If a typed lexical variable holding a reference is used to access a
+hash element and a package with the same name as the type has
+declared class fields using this pragma, then the operation is
+turned into an array access at compile time.
+
+=end original
+
+¥ê¥Õ¥¡¥ì¥ó¥¹¤òÊÝ»ý¤·¤Æ¤¤¤ë·¿ÉÕ¤­¥ì¥­¥·¥«¥ëÊÑ¿ô¤¬¥Ï¥Ã¥·¥åÍ×ÁǤΥ¢¥¯¥»¥¹¤Ë
+»È¤ï¤ì¡¢·¿¤ÈƱ¤¸Ì¾Á°¤Î¥Ñ¥Ã¥±¡¼¥¸¤¬¤³¤Î¥×¥é¥°¥Þ¤ò»È¤Ã¤Æ¥¯¥é¥¹¥Õ¥£¡¼¥ë¥É¤ò
+Àë¸À¤·¤Æ¤¤¤ë¤È¡¢¤³¤ÎÁàºî¤Ï¥³¥ó¥Ñ¥¤¥ë»þ¤ËÇÛÎó¥¢¥¯¥»¥¹¤ËÊÑ´¹¤µ¤ì¤Þ¤¹¡£
+
+=begin original
+
+The related C<base> pragma will combine fields from base classes and any
+fields declared using the C<fields> pragma.  This enables field
+inheritance to work properly.
+
+=end original
+
+´ØÏ¢¤¹¤ë C<base> ¥×¥é¥°¥Þ¤Ï¡¢´ðÄ쥯¥é¥¹¤Î¥Õ¥£¡¼¥ë¥É¤È
+C<fields> ¥×¥é¥°¥Þ¤ò»È¤Ã¤ÆÀë¸À¤µ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤ò·ë¹ç¤·¤Þ¤¹¡£
+¤³¤ì¤Ë¤è¤ê¥Õ¥£¡¼¥ë¥É¤Î·Ñ¾µ¤¬Å¬ÀÚ¤ËÆ°ºî¤¹¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+=begin original
+
+Field names that start with an underscore character are made private to
+the class and are not visible to subclasses.  Inherited fields can be
+overridden but will generate a warning if used together with the C<-w>
+switch.
+
+=end original
+
+²¼Àþʸ»ú¤Ç»Ï¤Þ¤ë¥Õ¥£¡¼¥ë¥É̾¤Ï¤³¤Î¥¯¥é¥¹¤Ë¥×¥é¥¤¥Ù¡¼¥È¤Ê¤â¤Î¤È¤Ê¤ê¡¢
+¥µ¥Ö¥¯¥é¥¹¤«¤é¤Ï¸«¤¨¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£
+·Ñ¾µ¤µ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤Ï¥ª¡¼¥Ð¡¼¥é¥¤¥É¤Ç¤­¤Þ¤¹¤¬¡¢
+C<-w> ¥ª¥×¥·¥ç¥ó¤È¤È¤â¤Ë»È¤ï¤ì¤ë¤È·Ù¹ð¤¬È¯À¸¤·¤Þ¤¹¡£
+
+=begin original
+
+B<Only valid for perls before 5.9.0:>
+
+=end original
+
+B<5.9.0 ¤è¤êÁ°¤Î perl ¤Ç¤Î¤ßÍ­¸ú:>
+
+=begin original
+
+The effect of all this is that you can have objects with named
+fields which are as compact and as fast arrays to access. This only
+works as long as the objects are accessed through properly typed
+variables. If the objects are not typed, access is only checked at
+run time.
+
+=end original
+
+¤³¤ì¤éÁ´¤Æ¤Î¸ú²Ì¤Ï¡¢ÇÛÎó¤ÈƱÍͤ˥³¥ó¥Ñ¥¯¥È¤Ç¹â®¤Ê¡¢Ì¾Á°ÉÕ¤­¥Õ¥£¡¼¥ë¥É¤ò
+»ý¤Ä¥ª¥Ö¥¸¥§¥¯¥È¤ò»ý¤Æ¤ë¤³¤È¤Ç¤¹¡£
+¤³¤ì¤Ï¥ª¥Ö¥¸¥§¥¯¥È¤¬Å¬Àڤ˷¿ÉÕ¤±¤µ¤ì¤¿ÊÑ¿ô¤òÄ̤·¤Æ¥¢¥¯¥»¥¹¤µ¤ì¤¿¾ì¹ç¤Ë¤Î¤ß
+Æ°ºî¤·¤Þ¤¹¡£
+¥ª¥Ö¥¸¥§¥¯¥È¤¬·¿ÉÕ¤­¤Ç¤Ê¤¤¾ì¹ç¡¢¥¢¥¯¥»¥¹¤Ï¼Â¹Ô»þ¤Ë¤Î¤ß¥Á¥§¥Ã¥¯¤µ¤ì¤Þ¤¹¡£
+
+=begin original
+
+The following functions are supported:
+
+=end original
+
+°Ê²¼¤Î´Ø¿ô¤ËÂбþ¤·¤Æ¤¤¤Þ¤¹:
+
+=over 4
+
+=item new
+
+=begin original
+
+B< perl before 5.9.0: > fields::new() creates and blesses a
+pseudo-hash comprised of the fields declared using the C<fields>
+pragma into the specified class.
+
+=end original
+
+B< perl 5.9.0 ¤è¤êÁ°: > fields::new() ¤Ï
+C<fields> ¥×¥é¥°¥Þ¤ò»È¤Ã¤ÆÀë¸À¤µ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤«¤é¤Ê¤ëµ¿»÷¥Ï¥Ã¥·¥å¤ò
+»ØÄꤵ¤ì¤¿¥¯¥é¥¹¤ËºîÀ®¤·¤Æ¡¢bless ¤·¤Þ¤¹¡£
+
+=begin original
+
+B< perl 5.9.0 and higher: > fields::new() creates and blesses a
+restricted-hash comprised of the fields declared using the C<fields>
+pragma into the specified class.
+
+=end original
+
+B< perl 5.9.0 °Ê¹ß: > fields::new() ¤Ï
+C<fields> ¥×¥é¥°¥Þ¤ò»È¤Ã¤ÆÀë¸À¤µ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤«¤é¤Ê¤ëÀ©¸Â¥Ï¥Ã¥·¥å¤ò
+»ØÄꤵ¤ì¤¿¥¯¥é¥¹¤ËºîÀ®¤·¤Æ¡¢bless ¤·¤Þ¤¹¡£
+
+=begin original
+
+This function is usable with or without pseudo-hashes.  It is the
+recommended way to construct a fields-based object.
+
+=end original
+
+¤³¤Î´Ø¿ô¤Ïµ¿»÷¥Ï¥Ã¥·¥å¤¢¤ê¤Ç¤â¤Ê¤·¤Ç¤âÍ­ÍѤǤ¹¡£
+¤³¤ì¤Ï fields ¥Ù¡¼¥¹¤Î¥ª¥Ö¥¸¥§¥¯¥È¤òºî¤ë¤¿¤á¤Î¿ä¾©¤¹¤ëÊýË¡¤Ç¤¹¡£
+
+=begin original
+
+This makes it possible to write a constructor like this:
+
+=end original
+
+¤³¤ì¤Ï¼¡¤Î¤è¤¦¤Ê¥³¥ó¥¹¥È¥é¥¯¥¿¤ò½ñ¤¯¤³¤È¤ò²Äǽ¤Ë¤·¤Þ¤¹:
+
+    package Critter::Sounds;
+    use fields qw(cat dog bird);
+
+    sub new {
+        my $self = shift;
+        $self = fields::new($self) unless ref $self;
+        $self->{cat} = 'meow';                          # scalar element
+        @$self{'dog','bird'} = ('bark','tweet');        # slice
+        return $self;
+    }
+
+=item phash
+
+=begin original
+
+B< before perl 5.9.0: > 
+
+=end original
+
+B< perl 5.9.0 ¤è¤êÁ°: > 
+
+=begin original
+
+fields::phash() can be used to create and initialize a plain (unblessed)
+pseudo-hash.  This function should always be used instead of creating
+pseudo-hashes directly.
+
+=end original
+
+fields::phash() ¤ÏÄ̾ï¤Î(bless ¤µ¤ì¤Æ¤¤¤Ê¤¤)
+µ¿»÷¥Ï¥Ã¥·¥å¤ÎºîÀ®¤È½é´ü²½¤Ë»È¤ï¤ì¤Þ¤¹¡£
+¤³¤Î´Ø¿ô¤Ïµ¿»÷¥Ï¥Ã¥·¥å¤òľÀܺî¤ëÂå¤ï¤ê¤Ë¾ï¤Ë»È¤ï¤ì¤ë¤Ù¤­¤Ç¤¹¡£
+
+=begin original
+
+If the first argument is a reference to an array, the pseudo-hash will
+be created with keys from that array.  If a second argument is supplied,
+it must also be a reference to an array whose elements will be used as
+the values.  If the second array contains less elements than the first,
+the trailing elements of the pseudo-hash will not be initialized.
+This makes it particularly useful for creating a pseudo-hash from
+subroutine arguments:
+
+=end original
+
+ºÇ½é¤Î°ú¿ô¤¬ÇÛÎó¤Ø¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤Î¾ì¹ç¡¢µ¿»÷¥Ï¥Ã¥·¥å¤Ï¤³¤ÎÇÛÎó¤ò
+¥­¡¼¤È¤·¤ÆºîÀ®¤µ¤ì¤Þ¤¹¡£
+2 ÈÖÌܤΰú¿ô¤¬»ØÄꤵ¤ì¤¿¾ì¹ç¡¢¤³¤ì¤ÏÍ×ÁǤ¬ÃͤȤ·¤Æ»È¤ï¤ì¤ëÇÛÎó¤Ø¤Î
+¥ê¥Õ¥¡¥ì¥ó¥¹¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£
+Æó¤ÄÌܤÎÇÛÎó¤ÎÍ×ÁÇ¿ô¤¬°ì¤ÄÌܤè¤ê¾¯¤Ê¤¤¾ì¹ç¡¢
+µ¿»÷¥Ï¥Ã¥·¥å¤Î»Ä¤ê¤ÎÍ×ÁǤϽé´ü²½¤µ¤ì¤Þ¤»¤ó¡£
+¤³¤ì¤ÏÆä˥µ¥Ö¥ë¡¼¥Á¥ó¤Î°ú¿ô¤«¤éµ¿»÷¥Ï¥Ã¥·¥å¤òºîÀ®¤¹¤ë¤Î¤ËÍ­ÍѤǤ¹:
+
+    sub dogtag {
+       my $tag = fields::phash([qw(name rank ser_num)], [@_]);
+    }
+
+=begin original
+
+fields::phash() also accepts a list of key-value pairs that will
+be used to construct the pseudo hash.  Examples:
+
+=end original
+
+fields::phash() ¤Ï¤Þ¤¿¡¢µ¿»÷¥Ï¥Ã¥·¥å¤ò¹½ÃÛ¤¹¤ë¤Î¤Ë»È¤ï¤ì¤ë
+¥­¡¼-ÃͤÎÁȤΥꥹ¥È¤â¼õ¤±ÉÕ¤±¤Þ¤¹¡£
+Îã:
+
+    my $tag = fields::phash(name => "Joe",
+                            rank => "captain",
+                            ser_num => 42);
+
+    my $pseudohash = fields::phash(%args);
+
+=begin original
+
+B< perl 5.9.0 and higher: >
+
+=end original
+
+B< perl 5.9.0 °Ê¹ß: >
+
+=begin original
+
+Pseudo-hashes have been removed from Perl as of 5.10.  Consider using
+restricted hashes or fields::new() instead.  Using fields::phash()
+will cause an error.
+
+=end original
+
+µ¿»÷¥Ï¥Ã¥·¥å¤Ï 5.10 ¤Ç Perl ¤«¤é¼è¤ê½ü¤«¤ì¤Þ¤·¤¿¡£
+Âå¤ï¤ê¤ËÀ©¸Â¥Ï¥Ã¥·¥å¤ä fields::new() ¤ò»È¤¦¤³¤È¤ò¸¡Æ¤¤·¤Æ¤¯¤À¤µ¤¤¡£
+fields::phash() ¤ò»È¤¦¤È¥¨¥é¡¼¤Ë¤Ê¤ê¤Þ¤¹¡£
+
+=back
+
+=head1 SEE ALSO
+
+L<base>
+
+=begin meta
+
+Translate: SHIRAKATA Kentaro <argra****@ub32*****>
+Status: completed
+
+=end meta
+
+=cut
+


perldocjp-cvs メーリングリストの案内
Back to archive index