Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: RFC: User subroutine hinting interface for autodie

by lodin (Hermit)
on Mar 07, 2009 at 17:50 UTC ( [id://749067]=note: print w/replies, xml ) Need Help??


in reply to RFC: User subroutine hinting interface for autodie

I like the subroutine idea for specifying hints. @_ could be the return values, and $_ aliased to $_[0]. Perhaps something like

autodie::hints->set_hints_for( \&foo, scalar => sub { ! $_ }, list => sub { ! @_ or @_ == 1 and ! defined }, ); autodie::hints->set_hints_for( \&copy, any => sub { ! $_ }, ); autodie::hints->set_hints_for( 'open', any => sub { ! defined }, );
would work.

This makes it easy to define common behaviours and to compose them in an arbitrary way.

use autodie::hints qw/ DEFAULT_SCALAR DEFAULT_LIST /; autodie::hints->set_hints_for( \&foo, scalar => DEFAULT_SCALAR, list => DEFAULT_LIST, ); use autodie::hints qw/ COND1 COND2 COND3 /; autodie::hints->set_hints_for( \&foo, any => sub { &COND1 and &COND2 or &COND3 }, );
If access to e.g. the arguments to the function is needed (for e.g. unlink) then that would have to be provided some other way, for instance via a localized global variable in autodie::hints.

Just an idea ...

lodin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://749067]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found