NAME
Hash::FieldHash - A lightweight fieldhash implementation
VERSION
This document describes Hash::FieldHash version 0.02.
SYNOPSIS
use Hash::FieldHash qw(:all);
fieldhash my %foo;
fieldhashes \my(%bar, %baz);
{
my $o = Something->new();
$foo{$o} = 42;
print $foo{$o}; # => 42
}
# now %foo is empty because $o is released
DESCRIPTION
Hash::FieldHash
provides the field hash mechanism which supports the inside-out technique.
You may know Hash::Util::FieldHash
. It's very useful module, but too complex to understand all the features and only available in 5.10. For pre-5.10, Hash::Util::FieldHash::Compat
may be available, but it's too slow to use.
This is compatible with H::U::F
, having simple interface and available in pre-5.10.
INTERFACE
Exportable functions
fieldhash(%hash)
-
Creates a field hash. The argument must be a hash.
Returns nothing.
fieldhashes(@hash_refs)
-
Creates any number of field hashes. All the arguments must be hash references.
Returns nothing.
FEATURES
Thread support
Hash::FieldHash
fully supports threading using the CLONE
method.
Relic support
Although Hash::FieldHash
uses a new feature introduced in Perl 5.10, the uvar magic for hashes described in "GUTS" in Hash::Util::Fieldhash, it also supports Perl 5.8 using the traditional tie-hash interface.
INCOMPATIBILITY
Hash::FieldHash
accepts only references and registered addresses as its keys, whereas Hash::Util::FieldHash
accepts any scalars.
According to "The Generic Object" in Hash::Util::FieldHash, Non-reference keys in H::U::F
are used for class fields. That is, all the fields defined by H::U::F
act as both object fields and class fields by default. If you do not want them to be class fields, you must check the type of $self explicitly. In addition, these class fields are never inherited. This function of H::U::F
seems erroneous, so Hash::FieldHash
restricts the type of keys.
DEPENDENCIES
Perl 5.8.1 or later, and a C compiler.
BUGS
No bugs have been reported.
Please report any bugs or feature requests to the author.
SEE ALSO
"Magic Virtual Tables" in perlguts.
AUTHOR
Goro Fuji <gfuji(at)cpan.org>.
LICENSE AND COPYRIGHT
Copyright (c) 2009, Goro Fuji. Some rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.