Skip to content
pannous edited this page Aug 30, 2021 · 4 revisions

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. raise stop the machine => catch stop the machine 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 when before after during once and whenever. (todo)

These Signal capturing keywords (after...) can also be used on variables to create (aspect oriented) implicit listeners:

x=10
once x==5 {print "countdown halfway done"}
while x-->0 : print x

Other than conditionals, listeners can react on access: set, get and change

x=10
on set x {print "x changed to " value}
while x-->0 👍🏻  

The signal event can be accessed within listeners with the signal/event keyword

These Signal capturing keywords can also be used on function names to create (aspect oriented) implicit listeners:

def test: print "test"
after tested: print "ok"
test()

Todo: shall event listeners be registrable post-hoc? that is should they semantically be pre inserted before the code by the compiler? The rational behind this is that events might be over before the listeners are properly registered

Home

Philosophy

data & code blocks

features

inventions

evaluation

keywords

iteration

tasks

examples

todo : bad ideas and open questions

⚠️ specification and progress are out of sync

Clone this wiki locally