Pooh program example 01-function-call-by-ref.p

Test 01-function-call-by-ref.p

Source of programm

# function call by reference , call by value

a = 'ccc'

println( ~msg a )

funbyref( ~arg a )

println( ~msg a )

funbyarg( ~arg a )

println( ~msg a )


sub funbyref( arg byref )
    arg = 'aaa'
end

sub funbyarg( arg )
    arg = 'bbb'
end



Standard output for 01-function-call-by-ref.p

ccc
aaa
aaa

Trace output for 01-function-call-by-ref.p

003|a = 'ccc'
005|println( ~msg a:'ccc' )...
007|funbyref( ~arg a:'ccc' )...
017| arg = 'aaa'
009|println( ~msg a:'aaa' )...
011|funbyarg( ~arg a:'aaa' )...
021| arg = 'bbb'
013|println( ~msg a:'aaa' )...