* Andrew Sterling Hanenkamp <[EMAIL PROTECTED]> [2003-12-17 21:03]:
> I've done some work with Tie::Memoize and really like it's
> interface, so I decided to write something like it for wrapping
> hashes. Thus, Tie::HashWrapper was born. It may be used like
> this:
> 
> tie my %wrappee, 'AnyDBM_File', ...;
> tie my %wrapper, 'Tie::HashWrapper', \%wrappee,
>       -deflate_value => sub { join ':', @{$_[0]} },
>       -inflate_value => sub { split /:/, $_[0] };
> 
> $wrapper{name} = [ value1, value2, value3 ];

I'd prefer if it didn't (ab)use the "minus on literal string".
There's nothing ambiguous in the syntax that might require it.

> Does Tie::HashWrapper seem reasonable? Or does anyone have a
> better name? Have I gone off the deep-end again and rewritten
> something that already exists and I missed it?

Sounds like what you're proposing is a special case of a
simplified interface to tieing in general. You're making life
easier for dealing with tied hashes by only having to deal with
the values. But it isn't necessary for the approach to be
specific to hashes.  With appropriate pass-through from of
parameters from FETCH and STORE, it would apply to any kind of
tie.

So I propose Tie::Simple as a collective namespace for generic
modules that offer a simplified interface to tieing and
Tie::Simple::Hash for this one.

A reason for this proposal is that I wouldn't use this module to
roll my own, like you're attempting; contrary to your sentiment,
I'd use MLDBM. I've used it before, and while it's a big wheel,
it also affords me the comfort of being able to change to a
different data structure, particularly to a more complex one,
instantly, should my needs ever expand. But there's need, IMO,
for a module that makes quick one-off uses of the tie mechanism
simpler than the cumbersome logistics required by vanilla Perl.

So that's what I believe would be a good goal to aim for.

-- 
Regards,
Aristotle
 
"If you can't laugh at yourself, you don't take life seriously enough."

Reply via email to