Files
swift-mirror/stdlib/core/REPL.swift
2013-06-28 02:31:01 +00:00

19 lines
447 B
Swift

// FIXME: Function types don't work yet as generic parameters
struct REPLExitHandler {
var f : () -> ()
}
var replExitHandlers : Vector<REPLExitHandler> = Vector<REPLExitHandler>()
func atREPLExit(handler:() -> ()) {
replExitHandlers.append(REPLExitHandler(handler))
}
func replExit() {
while replExitHandlers.length > 0 {
var handler = replExitHandlers[replExitHandlers.length-1]
replExitHandlers.popBack()
handler.f()
}
}