develooper Front page | perl.perl5.porters | Postings from June 2015

Re: Question/suggestion on perlfunc.pod example

Thread Previous | Thread Next
Aristotle Pagaltzis
June 21, 2015 06:11
Re: Question/suggestion on perlfunc.pod example
Message ID:
* Eric Brine <> [2015-06-21 07:30]:
> * Aristotle Pagaltzis <> [2015-06-20 01:55]:
> > Because there is NO reliable way of figuring out whether `do` failed
> > to find and read the file. Any failure that looks like `do`
> > signalling an I/O error can equally well have come from the code
> > inside the file. You have no way of telling apart whether a) the
> > `do` failed to locate and read the file or b) `do` did its job
> > successfully and ran the code but the code returned without a true
> > value and left $! populated with some error completely unrelated to
> > the `do`.
> Yes, buggy code could lead to the wrong error message being displayed.
> But at least it leads to an error message being displayed. Under the
> usage pattern you now recommend, buggy code will instead fail
> silently. That's bad.

No it won’t. It will fail to distinguish the source of the error, and
you have demonstrated this (redundantly, after I proposed to point out
this lack of reliability in the docs), but it will never fail silently
for failures of `do`, which you are welcome to try to disprove.

Of course if you have specific expectations about what value the code
in the file should return, and you do not check that the return value
fulfils those expectations, your code will have silent failures. That
has nothing to do with `do`, it is simply tautological.

Aristotle Pagaltzis // <>

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About