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

Re: Question/suggestion on perlfunc.pod example

Thread Previous | Thread Next
From:
Eric Brine
Date:
June 22, 2015 05:04
Subject:
Re: Question/suggestion on perlfunc.pod example
Message ID:
CALJW-qFqsFHWjvsAEMt3H5toP9fGE0HDnfib_NJ-7Mv=oqKaCg@mail.gmail.com
On Sun, Jun 21, 2015 at 2:11 AM, Aristotle Pagaltzis <pagaltzis@gmx.de>
wrote:

> * 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.
>

I didn't say "for failures of `do`". Both the old and new handle failures
of "do" just fine. They vary how they handle other failures. The current
boilerplate displays the wrong error message at worse. The new boilerplate
can hide an error message.

Current boilerplate:

The file can't be executed: The error in $! is displayed.
The code in the file throws an exception: The exception is displayed.
The code in the file erroneously returns undef: A proper error is displayed
or the error in $! is displayed. XXX

Suggested boilerplate:

The file can't be executed: The error in $! is displayed.
The code in the file throws an exception: The exception is displayed.
The code in the file erroneously returns undef: Nothing is displayed or the
error in $! is displayed XXX.

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