RosettaCodeData/Task/Scope-modifiers/Bc/scope-modifiers.bc

41 lines
958 B
Plaintext

define g(a) {
auto b
b = 3
"Inside g: a = "; a
"Inside g: b = "; b
"Inside g: c = "; c
"Inside g: d = "; d
a = 3; b = 3; c = 3; d = 3
}
define f(a) {
auto b, c
b = 2; c = 2
"Inside f (before call): a = "; a
"Inside f (before call): b = "; b
"Inside f (before call): c = "; c
"Inside f (before call): d = "; d
x = g(2) /* Assignment prevents output of the return value */
"Inside f (after call): a = "; a
"Inside f (after call): b = "; b
"Inside f (after call): c = "; c
"Inside f (after call): d = "; d
a = 2; b = 2; c = 2; d = 2
}
a = 1; b = 1; c = 1; d = 1
"Global scope (before call): a = "; a
"Global scope (before call): b = "; b
"Global scope (before call): c = "; c
"Global scope (before call): d = "; d
x = f(1)
"Global scope (before call): a = "; a
"Global scope (before call): b = "; b
"Global scope (before call): c = "; c
"Global scope (before call): d = "; d