alan
alan copied to clipboard
Conditionals
The Alan v0.2 conditionals concept is that if <conditional> { ... } else ...
is rewritten into cond
function calls where all function bodies are branchless and must run until the end.
This means return
statements are only valid as the last statement in a function body at that point.
This also means that conditional branches that don't return and pass back control flow to the higher layer must instead bolt on the follow-up code to the tail of their own function body. Excepting only if all branches of a conditional do not return, where fall-through is allowed, and all branches where the conditional does return, in which case follow-on code is a failure.
The cond
function will be just like any other function, so users can write their own that accepts something other than bool
s. This will be used for native GPGPU support, as both branches of a conditional need to be transformed into an AST to serialize to wgsl
for the GPU.