in reply to Re^2: OOP and derived classes
in thread OOP and derived classes
sub new { my ($class, %args) = @_; my $handlers; # change all nice_perlish_names into nicePerlishNames %args= _normalize_args( %args); # check options unless( $args{MoreOptions}) { foreach my $arg (keys %args) { carp "invalid option $arg" unless $valid_option{$arg}; } } # a twig is really an XML::Parser # my $self= XML::Parser->new(%args); my $self; $self= XML::Parser->new(%args); bless $self, $class; #... yadda yadda
and indeed it does inherit from XML::Parser @ISA = qw(XML::Parser);
This seems to be a highly complex module also playing with UNIVERSAL so I don't feel competent to comment.
I'd say the new() method is inherited but overridden, and instead of using SUPER::new() an explicit XML::Parser->new() is used to initialize a parent object and alter it.
Never used SUPER or Java so take it with a grain of salt, others with more expertise will comment soon on the basis of this post.
I hope it's obvious that analyzing XML::Twig is not the best way to start learning Perl's OOP. :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: OOP and derived classes
by Anonymous Monk on Feb 14, 2015 at 19:01 UTC | |
by Corion (Patriarch) on Feb 14, 2015 at 19:14 UTC | |
by LanX (Saint) on Feb 14, 2015 at 19:48 UTC |