From: Brian I. <in...@tt...> - 2002-08-19 18:38:41
|
On 19/08/02 14:27 -0400, Steve Howell wrote: > From: "Brian Ingerson" <in...@tt...> > > > > Perl can use this particular interface a bit more powerfully because it > > is list oriented: > > > > yaml_stream = YAML::dump(object_list) > > object_list = YAML::load(yaml_stream) > > > > This was actually a source of confusion, not convenience, for me in using the > yaml.pm interface, although I blame Perl culture, not yaml.pm, for it. > > How do you distinguish these case when using YAML::dump? > > 1) You have a list of objects that should be written as separate documents. > 2) You have an object that happens to be a list, but which should be written as > a single document. That's the beauty of Perl lists: they're not a data structure, they're a series of zero or more disjoint objects. I leverage this in YAML, because in YAML (not coincidentally) a stream is a series of zero or more disjoint documents. This doesn't apply as well to Python, because to emulate Perl list behaviour, you need to use a data structure, namely an array, (which to make matters ultimately confusing, Python calls a "list"). I'm not sure if Ruby has a Perl-list concept. Basically a list is really just a direct mapping of the call stack. Cheers, Brian |