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

Fatal keeps its ugly messages, autodie smells like roses.

From:
Paul Fenwick
Date:
June 4, 2008 05:31
Subject:
Fatal keeps its ugly messages, autodie smells like roses.
Message ID:
48468AF7.20008@perltraining.com.au
G'day Aristotle / p5p,

Executive summary:

	* Fatal won't get nicer errors.  It may break backwards
	  compatibility, and we can't give them the love they deserve.

	* If you want nice errors, s/Fatal/autodie/;  Easy.

	* If you think I'm wrong, now's a good time to say why.

Discussion:

Firstly, thanks for the excellent feedback.  I really do appreciate it, and 
sometimes your arguments are staggering hard to refute, which is why I 
haven't mentioned most of them in this post. ;)  That's a really good thing.

My main motivation for improving messages in Fatal is that whenever I 
mention it, there's huge enthusiasm from all the people who hate Fatal's 
errors, but who like the idea.  Because autodie sounds different, there's an 
immediate assumption that it must require more work to use/learn, even 
though one can essentially s/Fatal/autodie/;

I suspect the pivotal argument is going to come down to backwards 
compatibility.  I want developers to have the chance to change the 
stringification of errors, be it to support regional differences like 
language, or just because they don't like the defaults.  With my current 
architecture, changing the stringification table will modify how both 
autodie and Fatal exceptions work when treated as strings, because they both 
use the same code.

With autodie, we don't care.  You're not doing regexp matches against a 
string with autodie, you're interrogating the roles, or the filename, or the 
other information it exposes through methods.  The string is just something 
for your user to look at.  I'm hoping to see people who can 'use 
autodie::de' or 'use autodie::jp' to get errors in their native language.

With Fatal, we care hugely if the strings change significantly, even if it's 
  our own code that's doing it.  That big ball of mud module that we include 
and hasn't been touched in years *is* testing $@ against various string 
regexps, and it's fragile.

This means while we may be able to give Fatal nicer errors, we can't really 
give it the love it deserves.  ;(

As always, I'm still open to arguments, but the ease of s/Fatal/autodie/; 
and the risk of breaking existing code has me feel that Aristotle is right here.

Aristotle Pagaltzis wrote:

> That is a stronger argument, but it’s applicable only as long as
> it takes you to figure out how to make pragmata lexical in older
> perls (which you said appears to be possible), right?

autobox does it, so I assume it's possible.  The autobox code is extremely 
well documented, but I don't have my head around it yet.  It's certainly a 
much *easier* task in 5.10.

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



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