> > I need some tests of this new module.
> >
> > Thanks in advance.
> >
> > From POD:
> > ---------------------------------------------------
> >
> > =head1 NAME
> >
> > Hash::NoRef - A HASH that store values without increse the reference
count.
> >
> > =head1 DESCRIPTION
> >
> > This HASH will store it's values without increse the reference count.
> > This can be used to store objects but without interfere in the DESTROY
> > mechanism, since the
> > references in this HASH won't count.
>
> You need to define precisely what it is that the module does before
writing tests.
> You need to consider (and document in the POD) what exceptions can happen
> and how your module will handle them.
>
> This should be the basis for some of your tests.
>
> Are you talking about references to the HASH itself, or reference to its
members?
> From your POD this is not clear.
As the POD says:
HASH that store values without increse the reference count (of the values)
>
> > =head1 USAGE
> >
> > use Hash::NoRef ;
> >
> > my $hash = new Hash::NoRef() ;
> >
> > {
> > my $obj = new FOO() ;
> > $hash->{obj} = $obj ;
> > ## When we exit this block $obj will be destroied,
> > ## even with it stored in $hash->{obj}
> > }
> >
>
> Ah, looks like the hash members are the ones not adding to the reference
count.
>
> OK so, you are allowed to add scalars to the hash, without these scalars
> having their refcounts incremented.
>
> Why would you want to do this? After $obj has been DESTROYed, what is
> $hash->{obj} pointing to? eh? This will result in potential segfaults when
you
> attempt to access $hash->{obj}
Think a little and you will get the point. The idea is to can have a table
of objects, but wihtout touch the behavior of the objects. Soo, you can have
a table of objects, but it will work in the original scope and destroy
normaly. Why do that? Because if we need to have a table of object they will
live forever. For what I use? In 2 modules, RPO (Remote Perl Object) and
Safe::World. On RPO I use to have the references to the original objects,
and keep a cache of the remote object (bridge), so, I don't need to create a
new bridge always. In Safe::World is used to rebless automatically objects
created over shared objects.
>
> > ---------------------------------------------------
> >
> > This can be useful if you need to keep a table of objects, but don't
want to
> > mess with the "DESTROY mechanism".
>
> What are you offering over and above what weaken does in Scalar::Util?
As you said, do that in a wrong way will be a potential segfaults. So, this
need to be done right, and in a module easy do use. You asked for what we
will have in the hash if a object is destroied: we will have nothing. The
reference is removed from the hash automatically.
>
> > Just wait CPAN to write it at:
> > http://www.cpan.org/authors/id/G/GM/GMPASSOS/Hash-NoRef-0.01.tar.gz
>
> Another thought: how about using a tie interface? This would be more
natural
> for the programmer using your module.
It already have:
tie(%foo , 'Hash::NoRef') ;
>
> My $0.02
>
> Ivor.
>
Maybe I need to be more clear in the POD, you pointed to much doubts.
Regards,
Graciliano M. P.