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

Re: design questions

Thread Previous | Thread Next
Paul Fenwick
June 3, 2008 14:14
Re: design questions
Message ID:
G'day Abigail / p5p,

Abigail wrote:
> On Tue, Jun 03, 2008 at 07:17:28AM +1000, Paul Fenwick wrote:
>> I'd still really love feedback on my thoughts posted in my design questions 
>> e-mail[1], specifically:
>> 	* What should a plain 'no autodie' mean?

Wiggling wallabies, Batman!  I meant:

	* What should a plain 'use autodie' mean?

A plain 'no autodie' is a no-op (if no autodie behaviour enabled), disables 
all autodie features for the current lexical scope (if autodie enabled 
earlier), or an error if Fatal is in effect.

A plain 'use autodie' on the other hand, is much more interesting.  I was 
originally thinking it should mean:

	use autodie qw(:all);

enabling autodie for everything that the pragma knows how to change.  After 
the roles discussion with Larry and chromatic, I'm more inclined for it to mean:

	use autodie qw(:default);

The default role will initially include most or all of the core functions, 
but leaves open the possibility of user-defined subroutines wishing to 
declare themselves to have the default role (although doing so should be 
done with care).

> If I were to use 'autodie', I would like it to fatalise system() as well.

Good.  That matches what I want, too. ;)

> Will autodie have to option to cherry pick which functions are fatal, just

Yes, and this currently works with the current codebase.  However, what 
happens under the hood is that Fatal/autodie create functions in the calling 
package that have the same prototype, but examine hints in %^H to see if 
those functions should have fatal behaviour or not.

Since system doesn't have a prototype, it *still* breaks the exotic system 
even though autodie behaviour for system has been turned off; one still has 
to use CORE::system to use the exotic type.

However everything works as expected if the exotic version is not used:

       use autodie 'system';
       system("some_command");   # dies on failure

       no autodie 'system';
       system("some_command");   # lives on failure

Thanks very much indeed for the feedback, it's very much appreciated!



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

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