Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: RFC: User subroutine hinting interface for autodie

by pjf (Curate)
on Mar 05, 2009 at 12:54 UTC ( #748510=note: print w/ replies, xml ) Need Help??


in reply to Re: RFC: User subroutine hinting interface for autodie
in thread RFC: User subroutine hinting interface for autodie

What exactly am I setting? Is there an implied "The following list are failure indications"? In other words, would a more intuitive interface be sub => \&foo, fail => qw//?

My apologies for the lack of clarity in my original post. This is indeed an implied "here are a list of failure indications", as autodie's job is to throw exceptions automatically on failure.

[What about] Want or Contextual::Return?

I can say straight up that subroutines that use Want or Contextual::Return may cause headaches in combination with autodie. Those modules do very clever things when it comes to examining context, and autodie's intercept-and-inspect code may result in subtle changes. Autodie can't leverage their cleverness in any useful way, since (with one exception) it promises not to muck with a subroutine's return value(s).

What about letting the user define a new hint. Let's say I have a function that returns a SQL code. Some of these codes are errors and some of them aren't but only a lookup table will allow me to define this.

Yesterday, my response would be that this is beyond the scope of what autodie is intended to do, which is fundamentally remove the need to write or die... after far too many subroutine calls.

Today, after receiving a wonderfully in-depth e-mail from TheDamian, I'm fairly convinced that people will still try and use autodie for situations like you've just described, which has had me do a lot more thinking about what hints are applicable.

While I don't have everything in concrete yet, you can expect the final hints interface to allow one to pass a subroutine reference that can inspect the return and indicate if an exception should be thrown. That covers the situation of checking SQL return values in a table, or having subroutines that only fail if it's raining.

Many thanks again for the feedback and thoughts,


Comment on Re^2: RFC: User subroutine hinting interface for autodie

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-22 10:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (115 votes), past polls