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

Re: design questions

Thread Previous
Paul Fenwick
June 4, 2008 05:51
Re: design questions
Message ID:
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 line 5, near "} @args"

Not really pretty, the syntax error is spotted by Perl after it sees the 

	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.



Paul Fenwick <> |
Director of Training                   | Ph:  +61 3 9354 6001
Perl Training Australia                | Fax: +61 3 9354 2681

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