Closed mscha closed 11 years ago
Though I couldn't give a lick about "wasting" 16 bytes, making it even easier to dump in JSON and YAML makes sense to me.
I have reservations about XML. JSON and YAML are fairly straight forward translations, but XML is not. However, we don't even do XML yet so we can blow up that bridge when we come to it.
I request discussions about XML dumping happen in #231.
Since we're going to have more dumping methods, I'd suggest a
nomenclature change. as_blah
seems to be the standard name for
methods. This avoids cluttering the meta namespace with random formats
and makes it a bit clearer what they do and how to find them.
perl -> as_perl
yaml -> as_yaml
json -> as_json
This should be a fairly straight forward patch. The code is in
perl5i::2::Meta::Instance. The individual dumper methods exist as
perl
, _dump_as_json
and _dump_as_yaml
. Fiddle the names and the
tests in t/dump/
. Leave an alias from as_perl
to perl
for
compatibility and we can get rid of it in perl5i::3.
Go to it!
Now they just need to be documented in perl5i::Meta::Instance. Don't forget that perl
is now a backwards compatibility method and as_perl
is the real one.
Having to type $foo->mo->dump(format=>'yaml')->say is way too annoying. And it wastes 16 bytes and a couple of seconds every time you use it. Can we get $foo->mo->yaml->say as a shortcut, just like we have $foo->mo->perl->say ? (Same thing for json, and any other formats (xml?) that might be added for dump.)