tadman has asked for the wisdom of the Perl Monks concerning the following question:
DESCRIPTION
The "fields" pragma enables compile-time verified class fields.
# 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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use fields
by jmcnamara (Monsignor) on Jun 03, 2002 at 14:01 UTC | |
by perrin (Chancellor) on Jun 03, 2002 at 18:11 UTC | |
by jmcnamara (Monsignor) on Jun 03, 2002 at 22:07 UTC | |
|
Re: use fields
by Aristotle (Chancellor) on Jun 03, 2002 at 22:46 UTC |