On Mon, Jan 07, 2002 at 11:55:03AM +0000, Graham Barr wrote:
> On Sun, Jan 06, 2002 at 10:43:36PM +0000, Tim Bunce wrote:
> > > If people want per-DBI-handle data, why not provide the data via
> > > $dbh->private instead, which returns a hashref unique to the handle?
> >
> > And shared by all other classes/code which wants to use per-handle data.
> > Doesn't seem to be much of a win.
> >
> > Though it crosses my mind that a $h->private(__PACKAGE__, 'foo') interface
> > would at least force people to consider namespace polution/protection.
>
> This is similar to what we did in Tk a long time ago. There is a method
> ->private which takes an optional package name, if the package is
> not given it defaults to the callers package. It simply returns a hashref
> for the caller to use. It was meant for subclasses to store thier own data
> without clashing. The code for Tk was something like
>
> sub private {
> my $self = shift;
> my $pkg = shift || caller;
> return $self->{private_data}{$pkg} ||= {};
> }
Yes, thanks Graham. I may well add something along those lines for use by
subclasses. >>todo.
Tim.