Pull requests

#13 Declined
Repository
tobyink/p5-xml-libxml p5-xml-libxml
Branch
default
Repository
shlomif/perl-XML-LibXML perl-XML-LibXML
Branch
default

overload array derefand hash deref for XML::LibXML::Element

Author
  1. Toby Inkster
Reviewers
Description

This allows:

foreach my $child (@$element) {
  ...
}

to work. And also allows you to replace:

$element->getAttribute('foo')

with the much shorter:

$element->{foo}
  • Learn about pull requests

Comments (1)

  1. Shlomi Fish repo owner

    Hi Toby,

    first of all, I should note that you forgot to add the new file to the MANIFEST (maybe I should get my act together and define a MANIFEST.SKIP file).

    In any case, I'm not sure I like the direction of this patch. There may be several ways to interpret hash ref and array ref overloading in the context of XML, and while this patch appears to be convenient, it may be deceptively misleading.

    Did you think what would happen if the user tries to access a non-existing slot in the array/hash? Is it a read-only interface or can I also write? I also don't like the XML-Simple-like feel of it.

    I will still consider it because it seems convenient, but first:

    1. Add the file to the MANIFEST.

    2. Provide some examples in the documentation (like the illustrative ones in the pull request).

    3. Add a comment to the Changes file.