Skip to content

Nested function calls

Julius Paffrath edited this page Apr 17, 2017 · 3 revisions

Have you ever asked yourself what the following snippet will produce?

function my(num)
    assign num plus 1 to num
    return num
end

print(my(my(0)))

You are right! The output will be

jask ~> 2.0

The interpreter first executes my(0). Because a value was pushed and not a variable, a new variable is locally created on the function heap. The heap will be transfered to the second my() call and furthermore to the print call where it is destroyed.

Clone this wiki locally