&new: Extended for passing arguments to the add-on &TIEHASH-es.
authorshort <>
Sat, 17 Sep 2005 12:02:07 +0000 (12:02 +0000)
committershort <>
Sat, 17 Sep 2005 12:02:07 +0000 (12:02 +0000)
Hash.pm

diff --git a/Hash.pm b/Hash.pm
index 69204e4..280c26b 100644 (file)
--- 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;