From 1c18d205aecccd477103e8c37e07f1a92f20bca6 Mon Sep 17 00:00:00 2001 From: short <> Date: Sat, 17 Sep 2005 12:02:07 +0000 Subject: [PATCH] &new: Extended for passing arguments to the add-on &TIEHASH-es. --- Hash.pm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Hash.pm b/Hash.pm index 69204e4..280c26b 100644 --- a/Hash.pm +++ b/Hash.pm @@ -29,20 +29,24 @@ use Carp qw(cluck confess); # OK, this is just @ISA 'runtime' reimplementation using: ->{"parent"} # Creating classes each time is too complicated in Perl. # Maybe the best would be run-time generation of the classes using: @ISA -# This way the feature implementations could use SUPER::... instead of: pass(...) +# This way the feature implementations could use SUPER.pm calls instead of: pass(...) +# My::Hash::KIND->new($parent,@optional_KIND_arguments); +# My::Hash->new($parent,"My::Hash::KIND_OUTER",["My::Hash::KIND_INNER",@optional_KIND_INNER_arguments]); sub new($$;@) { my($class,$parent,@classes)=@_; - unshift @classes,$class if $class ne __PACKAGE__; - for my $pkg (reverse @classes) { + @classes=[$class,@classes] if $class ne __PACKAGE__; + for my $item (reverse @classes) { + my $pkg=(!ref($item) ? $item : $item->[0]); + my @args=@{$item}[1..$#$item] if ref $item; local $_=$pkg.".pm"; s{::}{/}g; require $_; my %hash; - tie %hash,$pkg,$parent; + tie %hash,$pkg,$parent,@args; $parent=\%hash; } return $parent; -- 1.8.3.1