-
-
Notifications
You must be signed in to change notification settings - Fork 4
signal
Signals can be broadcasted from any branch of any thread at any time using send
raise
or throw
.
They can be received in multiple locations using the catch
and on
keywords.
Unlike errors, which are value types, exceptions are special signals which can only be received higher up in the call stack.
fun check the surroundings {
if man nearby:
raise stop the machine!
}
fun main {
go check the surroundings // asynchronous
on stop the machine{
cancel everything
panic
exit
}
}
Because errors have their own value mechanism, using signals for control flow is encouraged.
By default a signals type is its name which need not be quoted. As everything in angle, Signals can be structured data as well, and metadata can be added effortlessly:
raise stop the machine{ time:now reason:"human in danger!"}
Signals can also be broadcast outside the application and runtime context, via the broadcast
function and via well configured repeaters.
Signals can also be received from outside the application and runtime context, via well configured channel listeners. This functionality is part of the standard library and not of the language abi (except for standardized serialization) and seemingless integration with the above on
keyword, as well as once
and whenever
. (todo)