in reply to Re^5: Hooks like Storable for Dumper?
in thread Hooks like Storable for Dumper?
I like it. Among other things, it might allow one serializer to fall back to another. E.g. if YAML doesn't find a freezer defined for it, it could theoretically fall back to DDS.
The only other way that I think might make sense is for a package to have the hash, e.g.
our %FREEZE_THAW_FOR; %FREEZE_THAW_FOR{ "Data::Dump::Streamer" } = [ 'foo', '->bar' ]; %FREEZE_THAW_FOR{ "Data::Dumper" } = [ 'foo', 'bar' ]; %FREEZE_THAW_FOR{ "YAML" } = [ 'foo', 'bar' ];
It all amounts to the same thing really -- mapping between packages and serializers in some package variable space. I think I moderately prefer your approach, though a part of me is leery of the globals either way. Seems like there ought to be a better way -- maybe a third party module that packages can register with and serializers can query, but then you wind up in dependency hell.
I think the KISS and YAGNI principles would suggest doing it your way.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Hooks like Storable for Dumper?
by demerphq (Chancellor) on Jan 03, 2006 at 19:20 UTC | |
by xdg (Monsignor) on Jan 03, 2006 at 20:13 UTC |