ExitFunction

From Erights

Jump to: navigation, search

Currently hypothetical as a guard and auditor. Ejectors and throw are existing examples of ExitFunctions.

An ExitFunction is an object whose run/1 method does not return, and has no side effects before it exits. That is, calling an ExitFunction's run/1 cannot be plan interference.

In the below example, it is guaranteed that println("okay") will happen before any effects specific to ef occur, and that println("oops") will not happen.

def example(ef :ExitFunction) {
    try {
        ef("boo")
    } finally {
        println("okay")
    }
    println("oops")
}

Proposal

User:Kevin Reid proposes that parameters which are expected to be ejectors should be guarded by ExitFunction instead of OneArgFunc, except where the programmer has considered the possibility of plan interference.

See also Non-optional ejectors.

Personal tools
more tools