develooper Front page | perl.perl5.porters | Postings from January 2022

Re: Broken stack traces from use statements.

Thread Previous | Thread Next
From:
demerphq
Date:
January 16, 2022 06:54
Subject:
Re: Broken stack traces from use statements.
Message ID:
CANgJU+WwV=zrcUtzkJATDkQgnkmPHim1+3fN=rt6WHR+ZO2uDQ@mail.gmail.com
On Sat, 15 Jan 2022 at 14:27, Leon Timmermans <fawaka@gmail.com> wrote:

> On Sat, Jan 15, 2022 at 8:22 AM demerphq <demerphq@gmail.com> wrote:
>
>>
>> As far as I can tell, it's an accurate representation of how the sausage
> is made. BEGIN blocks aren't implemented the way one would expect them to,
> and these stacktraces represent that. They're not false, just very
> unhelpful.
>

I really don't understand your position on this. We see output that says 4
contradictory things, none of which are actually accurate. So which one of
the four is true and which ones are false?  I dont think the following
statements can all be true simultaneously.

main::BEGIN() called at A.pm line 2
main::BEGIN() called at B.pm line 2
main::BEGIN() called at C.pm line 2
main::BEGIN() called at D.pm line 2

But main::BEGIN is actually called at -e line 1. I mean, if the BEGIN
statement were created in a module it would would A::BEGIN or B::BEGIN. For
example:

$ perl -MCarp=cluck -le'package Foo; BEGIN { Carp::cluck("in begin") }'
in begin at -e line 1.
Foo::BEGIN() called at -e line 1
eval {...} called at -e line 1

I really think this is an important point that keeps getting lost. Sure you
can say "this is how the sausage is made", as this is the result of using a
single global to track the origin of ALL synthesized BEGIN blocks which are
part of a use statement. But that is circular logic. "it is correct and
true because that is how it works" could be used to justify leaving unfixed
ANY bug we encounter.

If the output did not say "called at A.pm line 2" but said "fake-frame
injected by compiler" or something like that, I could buy the "this is how
the sausage is made" argument. But it doesn't. It says something different
each time. None of which seem to have any relationship to reality.

It seems to me we should be able to agree on whether the output is true,
and whether it is correct. I am really struggling to understand why this is
controversial. It seems to me we should be able to agree that main::BEGIN
*cannot* be called from anywhere but main, and this means that the output
claiming that the block was called from a module file cannot be correct.

Cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


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