I would like to revise my original query into a proposal in light of the
comments I've received to now suggest a Tie::Filter namespace for
filtering Tie classes. There could be specialized classes
Tie::Filter::Scalar, Tie::Filter::Array, Tie::Filter::Hash, and
Tie::Filter::Handle.

However, at this point, this project is becoming far more serious than
the original idea and I think I'm going to need an actual design for
each of these. The implementations will all be tiny, but I want an
interface that seems natural. Really, the only API that these modules
have to come up with are the arguments to tie, so I propose the
following syntax for calls to tie:

For all Tie::Filter classes, the first argument will always be a
reference to the wrapped object. The wrapped object must be of the same
type as the tie itself since the Tie::Filter class does the work of
actually manipulating the internal object. (Becoming any more general
and we've just invented a new way of implementing a tied object and I
don't really think that's necessary.)

Tie::Filter::Scalar:

tie $scalar, 'Tie::Filter::Scalar', \$wrapped,
        INFLATE => sub { ... },
        DEFLATE => sub { ... },

Tie::Filter::Array:

tie @array, 'Tie::Filter::Array', [EMAIL PROTECTED],
        INFLATE => sub { ... },
        DEFLATE => sub { ... };

Tie::Filter::Hash:

tie %hash, 'Tie::Filter::Hash', \%wrapped,
        INFLATEKEY => sub { ... },
        DEFLATEKEY => sub { ... },
        INFLATEVALUE => sub { ... },
        DEFLATEVALUE => sub { ... };

Tie::Filter::Handle:

tie $handle, 'Tie::Filter::Handle', \$handle,
        INFLATE => sub { ... }, # stream read
        DEFLATE => sub { ... }; # stream write

I think I like these keys better than the -inflate*/-deflate* ones I
presented before.

Any other suggestions? I'll keep working on this and am glad to take any
other suggestions. Thank you all for your suggestions; they have been
very helpful.

Regards,
Sterling
-- 
<>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><> <>< ><>
  Andrew Sterling Hanenkamp
  http://Andrew.Sterling.Hanenkamp.com/
  [EMAIL PROTECTED] / [EMAIL PROTECTED]

  Keep me informed on the behaviour of this kernel..  As the
  "BugFree(tm)" series didn't turn out too well, I'm starting a new
  series called the "ItWorksForMe(tm)" series, of which this new 
  kernel is yet another shining example.
                       -- Linus, in the announcement for 1.3.29
        

Reply via email to