Skip to content

Expression Definition Statement

IsaacShelton edited this page Mar 21, 2022 · 1 revision

Expression Definition Statement

Commonly used expressions can be assigned a name via the define keyword

define distance = sqrtf(x * x + y * y)

Re-evaluation

Since expression definitions just assign a name to an expression, they are re-evaluated each time they are used.

import basics

func main {
    x int = 0
    define next_x = ++x
    
    repeat 3, print(next_x)
}
1
2
3

If this is behavior is undesired, you should use const variable declarations instead.

Clone this wiki locally