Skip to content

Procedure declarations

Procedures are declared with the method keyword.

The accepted parameters are declared in parentheses after the method name and are separated by commas.

If there are variables outside the scope of the function with the same name as the parameters, they are ignored, so there is no shadowing, however for readability this is not recommended.


Example

method draw_square_to_circle($x, $y, $newX, $newY) {
    square { pos { x: $x, y: $y } }
        -> x2
        -> x2
        -> rotate90a
        -> circle {
            pos {
                x: $newX,
                y: $newY
            }
        }!
}

The procedure can then be called as follows, for example:

draw_square_to_circle(100, 100, 200, 200)

Note that procedures are unrolled at compile time, similarly to macros, and therefore cannot rely on runtime-related values or features.