Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Perl 6 has baked in some stuff @Larry may have stolen from CL that is intended to enable unified succinct expression of desired sync or async handling in response to errors and callstack events (including exceptions).


Having something like CL Condition System in Perl6 would be very nice!

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.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: