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

Re: Question/suggestion on perlfunc.pod example

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
June 21, 2015 06:11
Subject:
Re: Question/suggestion on perlfunc.pod example
Message ID:
20150621061109.GA47714@plasmasturm.org
* Eric Brine <ikegami@adaelis.com> [2015-06-21 07:30]:
> * Aristotle Pagaltzis <pagaltzis@gmx.de> [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.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About