John Porter wrote: > Note that END{} and BEGIN{} require no formal introduction. > You can put them anywhere you want, and they run at the proper time. > > Even continue{} is an implicit goto. And it requires no introduction > either. So if a post{} block could appear anywhere inside a block, like an END{} block inside a program (or an eval"" text?) and mean "do this code on leaving this block, but before scope destruction (which might be arbitrarily deferred)" would we call the post blocks that hadn't been reached, on exiting? I think not: sub has_post_blocks{ my $i = 3; post { print "i ended up as $i"}; my $arg1 = shift; $arg1 > 4 or die "arg1 ($arg1) too small"; my $j = 2; post { print "j ended up as $j"}; ... }; might only print the message about i when arg1 is too small. This would allow informational messages to be declared at the beginning, for instance. It would be implemented by pushing the post block onto the list of things to do at scope exit, at run time. testing eval"END{...}"... perl -nle 'print 0; $_ and eval "BEGIN{print 1};END{print 2}"; print 3' stacks up all the C<print 2> blocks until you give it an EOF, rather than doing them on exiting the eval space. BEGIN is not at this time capable of backing up time to before I entered a true value, so it prints out the 1 as soon as it knows it is supposed to.
- Re: assign to magic name-of-function variable instead of &... abigail
- Re: assign to magic name-of-function variable instead... John Porter
- Re: assign to magic name-of-function variable instead... Tony Olekshy
- Re: assign to magic name-of-function variable instead... John Porter
- Re: assign to magic name-of-function variable instead... Peter Scott
- Re: assign to magic name-of-function variable instead... John Porter
- Re: assign to magic name-of-function variable instead... Peter Scott
- Re: assign to magic name-of-function variable instead... David L. Nicol
- Re: assign to magic name-of-function variable instead... John Porter
- Re: assign to magic name-of-function variable instead... Peter Scott
- Re: assign to magic name-of-function variable instead... David L. Nicol
- Re: assign to magic name-of-function variable instead... Nicholas Clark
- POST blocks (like END, but in a sub or sub-like scope... David L. Nicol
- Re: POST blocks (like END, but in a sub or sub-like s... Nicholas Clark
- Re: POST blocks (like END, but in a sub or sub-like s... David L. Nicol
- Re: POST blocks (like END, but in a sub or sub-like s... Nicholas Clark
- Re: POST blocks (like END, but in a sub or sub-like s... Bart Lateur
- Re: POST blocks (like END, but in a sub or sub-like s... John Porter
- Re: POST blocks (like END, but in a sub or sub-like s... John Porter
- Re: assign to magic name-of-function variable instead... Glenn Linderman
- Re: assign to magic name-of-function variable instead of &... Glenn Linderman