Closed p5pRT closed 20 years ago
I think CHECK and INIT blocks should trigger a warning if they are not going to be executed.
[1]D:/: cat bcie.pl BEGIN { print "in begin\n"; } CHECK { print "in check\n"; } INIT { print "in init\n"; } END { print "in end\n"; } print "in mainline\n"; 1; [2]D:/: perl -We 'require "bcie.pl"' in begin in mainline in end [3]D:/: perl -We 'do "bcie.pl"' in begin in mainline in end
On Sun\, 12 Mar 2000 09:22:25 PST\, Yitzchak Scott-Thoennes wrote:
I think CHECK and INIT blocks should trigger a warning if they are not going to be executed.
[1]D:/: cat bcie.pl BEGIN { print "in begin\n"; } CHECK { print "in check\n"; } INIT { print "in init\n"; } END { print "in end\n"; } print "in mainline\n"; 1; [2]D:/: perl -We 'require "bcie.pl"' in begin in mainline in end
Check this out.
Sarathy gsar@ActiveState.com
warn about CHECK and INIT blocks encountered at run time
Why not schedule those for end-of-file/eval execution?
while compiling unit { if a CHECK or INIT seen too late push coderef on end-of-unit execution stack } foreach item in delayed execution stack run it
--tom
On Sat\, 18 Mar 2000 20:47:37 MST\, Tom Christiansen wrote:
warn about CHECK and INIT blocks encountered at run time
Why not schedule those for end-of-file/eval execution?
while compiling unit { if a CHECK or INIT seen too late push coderef on end-of-unit execution stack } foreach item in delayed execution stack run it
Good idea\, but this is going to only hurt more than it helps until we figure out how to compile individual modules into distinct units. It also needs more per-file infrastructure than we presently have (to hang those INITs on to\, for instance).
Anyway\, this is something for the Todo list.
Sarathy gsar@ActiveState.com
In article \200003190427\.UAA28076@​maul\.ActiveState\.com\, Gurusamy Sarathy \gsar@​ActiveState\.com wrote:
On Sat\, 18 Mar 2000 20:47:37 MST\, Tom Christiansen wrote:
warn about CHECK and INIT blocks encountered at run time
Why not schedule those for end-of-file/eval execution?
while compiling unit { if a CHECK or INIT seen too late push coderef on end-of-unit execution stack } foreach item in delayed execution stack run it
Good idea\, but this is going to only hurt more than it helps until we figure out how to compile individual modules into distinct units. It also needs more per-file infrastructure than we presently have (to hang those INITs on to\, for instance).
Anyway\, this is something for the Todo list.
Yup. I didn't see the warnings as being a permanent fix. WRT Tom's suggestion\, *perhaps* INIT blocks could be "promoted" to BEGIN blocks (or be run after all the BEGIN blocks in this parse phase) but I don't know that the same is true for CHECK blocks.
Migrated from rt.perl.org#2349 (status was 'resolved')
Searchable as RT2349$