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

Re: design questions

June 2, 2008 12:36
Re: design questions
Message ID:
On Mon, Jun 02, 2008 at 06:42:59PM +0200, Roland Giersig wrote:
> Abigail wrote:
> >What's the point of changing the meaning of something, and then,
> >when someone uses the new meaning, give a warning the meaning was
> >changed?
> Good point.  Would it be better to deprecate Fatal (with a warning) and 
> tell people to use Fatal::Globally and Fatal::Locally instead?  OK, 
> forget about that, let's just call ist autodie and be done with it, 
> given that we just can remove Fatal from the docs and have autodie take 
> its place.


Furthmore, 'autodie' is all lowercased, that is, it looks like a pragma,
and it acts like a pragma in the sense that it is lexically scoped.

'Fatal', however, starts with a uppercase letter, and hence one shouldn't
expect it to behave locally.

> > Who's going to benefit from that?
> I was thinking about adding dwimmage to Fatal to "fix" the error-prone 
> behaviour.  If that is feasible, everybody would benefit from it.

You are assuming here that the current Fatal is error-prone. Do you have
any evidence to back this up?

> >How often do you see people posting code where they used Fatal
> >inside a block, wrongly assuming it would not raise a fatal error outside
> >of the block?
> I don't know, do you have any statistics?

I cannot recall ever seeing code where the author used Fatal as if it
had lexical effects.

> What are the consequences of silently making Fatal work on a local scope 
> instead of globally? It would make code that before died with a Fatal 
> error message now either die at a different location due to some 
> undefinedness (which IMHO is acceptable) or just give a warning and 
> produce wrong results (which in some cases is not acceptable).

I'd argue that even your first case isn't acceptable:

    {use Fatal;}

    open my $in,  "<", 'does_not_exist';
    open my $out, ">", 'does_exists';
    print $out <$in>;

This will have wiped out the content of 'something' if you had your way
in changing the semantics of Fatal.

> Is there a way to see if the Fatalized statement is followed by error 
> handling code? Am I insane to ask such a question? I think I need a beer...

I think that Pauls approach, leaving as is and creating a lexically
scoped autodie is the best way. 

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