I've only seen the try/CATCH stuff. Are there any examples of restart/resume/continue handlers ala CL?
BTW: Here's the Perl5 Condition System module I was thinking of (though there maybe others) - https://metacpan.org/pod/ConditionSystem
I've only seen the try/CATCH stuff. Are there any examples of restart/resume/continue handlers ala CL?
BTW: Here's the Perl5 Condition System module I was thinking of (though there maybe others) - https://metacpan.org/pod/ConditionSystem
CONTROL { print 1; $_.resume }; print 2; warn; print 3 # 213
That's obviously a contrived example but I think it shows the basics.Some related excerpts from spec doc S04 (blocks and statements):
Warnings are produced in Perl 6 by throwing a resumable control exception to the outermost scope, which by default prints the warning and resumes the exception by extracting a resume continuation from the exception, which must be supplied by the warn() function (or equivalent).
...
Since warnings are processed using the standard control exception mechanism, they may be intercepted and either suppressed or fatalized anywhere within the dynamic scope by supplying a suitable CONTROL block.
...
As with calls to return, the warning control exception is an abstraction that the compiler is free to optimize away (along with the associated continuation) when the compiler or runtime can determine that the semantics would be preserved by merely printing out the error and going on.
...
One additional level of control is the notion of lazy warnings. ... Numeric and string conversions use these lazy warnings to allow (but not require) failsoft semantics.