Closed skejeton closed 11 months ago
Many languages have adopted the defer
keyword, like Go's defer
and C3's defer
.
@skejeton for your specific use case I could add an atexit
to tophat, but I think it would be better to see it being an umka feature.
Defer seems to exit on the end of scope, not exactly what I want it appears
On Sun, Oct 16, 2022, 2:40 AM Rob Loach @.***> wrote:
Many languages have adopted the defer keyword, like Go's defer https://go.dev/tour/flowcontrol/12 and C3's defer https://www.c3-lang.org/examples/#defer.
— Reply to this email directly, view it on GitHub https://github.com/vtereshkov/umka-lang/issues/219#issuecomment-1279828499, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGOSLSMMWL6JWNDBTM3ZEOTWDMJCZANCNFSM6AAAAAAQ2P4QYQ . You are receiving this because you authored the thread.Message ID: @.***>
The reported use case is now covered by window.onDestroy.register({/*...*/})
in tophat.
atexit
allows you to run some code before exit. In my case I want to save the editor layouts and other code when the program exits. I can do it at the end of main, but in case of runtime errors or other preemptive exits or multiple exit points, the program may not save the data I want.