Lines Matching defs:fields

1 package fields;
23 # The %attr hash holds the attributes of the currently assigned fields
28 # in the case of base class private fields (which occupy a slot but are
37 my $fields = \%{"$package\::FIELDS"};
41 # Quiet pseudo-hash deprecation warning for uses of fields::new.
45 and ($fields->{$_[0]} || 0) >= $fattr->[0])
47 # There are already fields not belonging to base classes.
52 my $fno = $fields->{$f};
68 $fields->{$f} = $next;
74 # module was reloaded, but they appear to be declaring fields
76 # bookkeeping) that the rest of the fields will be declared or
79 Carp::croak ("Reloaded module must declare all fields at once");
96 my $fields = \%{"$pkg\::FIELDS"};
97 for my $f (sort {$fields->{$a} <=> $fields->{$b}} keys %$fields) {
98 my $no = $fields->{$f};
173 fields - compile-time class fields
179 use fields qw(foo bar _Foo_private);
183 $self = fields::new($self);
202 use fields qw(baz _Bar_private); # not shared with Foo
205 my $self = fields::new($class);
206 $self->SUPER::new(); # init base fields
207 $self->{baz} = 10; # init own fields
215 The C<fields> pragma enables compile-time verified class fields.
217 NOTE: The current implementation keeps the declared fields in the %FIELDS
226 declared class fields using this pragma, then the operation is
230 The related C<base> pragma will combine fields from base classes and any
231 fields declared using the C<fields> pragma. This enables field
235 the class and are not visible to subclasses. Inherited fields can be
242 fields which are as compact and as fast arrays to access. This only
254 B< perl before 5.9.0: > fields::new() creates and blesses a
255 pseudo-hash comprised of the fields declared using the C<fields>
258 B< perl 5.9.0 and higher: > fields::new() creates and blesses a
259 restricted-hash comprised of the fields declared using the C<fields>
263 recommended way to construct a fields-based object.
268 use fields qw(cat dog bird);
272 $self = fields::new($self) unless ref $self;
282 fields::phash() can be used to create and initialize a plain (unblessed)
295 my $tag = fields::phash([qw(name rank ser_num)], [@_]);
298 fields::phash() also accepts a list of key-value pairs that will
301 my $tag = fields::phash(name => "Joe",
305 my $pseudohash = fields::phash(%args);
310 restricted hashes or fields::new() instead. Using fields::phash()