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

Re: autodie.pm design questions

Thread Previous
From:
Paul Fenwick
Date:
June 4, 2008 05:51
Subject:
Re: autodie.pm design questions
Message ID:
48468FD4.1010802@perltraining.com.au
Roland Giersig wrote:

> But now the  prototype doesn't match the exotic form, so when the
 > parser encounters this, he dies.  With what error message?

Syntax error at example.pl line 5, near "} @args"

Not really pretty, the syntax error is spotted by Perl after it sees the 
close-brace:

	system { $cmd } @args;

 > Is it possible to intercept  the message and substitute a better one,
 > so that a "syntax error" or "doesn't match prototype" becomes

No way that I can see without changing perl or using source filters.  My 
argument is that even though the error message is obscure, the exotic form 
of system is so rare that most people don't even know it exists, let alone 
use it.

The big time I see this coming as a surprise is when people are converting 
existing code from Fatal to autodie, at which point after they 
s/Fatal/autodie/; and they get a syntax error, I hope they'll read the 
documentation. ;)

> Coming to think of, what does this do:
> 
>   use autodie qw(open);
>   use autodie qw(system);
> 
> Is open still autodieing after the second line? I would hope so.

It certainly is, at least until the end of the current lexical scope.  You 
can even:

	use autodie qw(:io);
	no autodie qw(open);

to have all functions with the :io role enable autodie behaviour, *except* 
for open.  That also works right now with the current build.

Cheerio,

	Paul

-- 
Paul Fenwick <pjf@perltraining.com.au> | http://perltraining.com.au/
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

Thread Previous


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