result - pannous/angle GitHub Wiki

The result keyword yields a special variable which is set to the last declaration or the return value of the last function call. ⚠️ Since everything in angle is an expression, the special result variable is also set in code such as

if 1>0 : print "hi" else : print "ho"
print result  # => "hi" !

Internal note: To avoid code bloat and optimize speed, the result mechanism is only used immediately before the keyword result occurs. Todo: really? It's just an internal variable which is exposed to the ABI without any overhead. todo : but wasm can't tee the previous stack!?

def foo: hi=2*2
foo
result # => 4 OR void ??

The result keyword is similar to the it keyword when no binding context is available.

Functions which return void 'return' the last value in the result slot. Todo: bad concept? side effects and information leakage.