bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-apl] Feature request: UNWIND-PROTECT-like feature


From: Elias Mårtenson
Subject: [Bug-apl] Feature request: UNWIND-PROTECT-like feature
Date: Mon, 21 Apr 2014 17:34:33 +0800

We need a feature similar to the Common Lisp form UNWIND-PROTECT, or in Java: try/finally.

For those who don't know, this form allows you to execute code after some code has been run, regardless of how the latter exits (return normally, exited with error, etc...)

What I envision is something like this:

    {2÷0} ⎕UnwindProtect {⎕←'hello'}

This code would print "hello" even though the left-hand _expression_ yielded an error.

I'd also like to see some information regarding the nature of the exit (return value of the left-hand form or error information) passed along in ⍵ and ⍺ to the right-hand function.

A construct like this is necessary to create safe forms for dealing with, for example, SQL transactions safely. It will also be needed in the file utility library that I will be writing.

I could, of course, implement this as a native library but I feel this is a feature that belongs in the core (since it's so important).

Regards,
Elias

reply via email to

[Prev in Thread] Current Thread [Next in Thread]