RosettaCodeData/Task/Variables/Logo/variables.logo

21 lines
643 B
Plaintext

make "g1 0
name 2 "g2 ; same as make with parameters reversed
global "g3 ; no initial value
to func :x
make "g4 4 ; still global
localmake "L1 6
local ["L2 "L3] ; local variables, collection syntax
func2 :g4
print :L2 ; 9, modified by func2
print :L3 ; L3 has no value, was not modified by func2
end
to func2 :y
make "g3 :y
make "L2 :L1 + 3 ; dynamic scope: can see variables of callers
localmake "L3 5 ; locally override L3 from caller
(print :y :L1 :L2 :L3) ; 4 6 9 5
end
print :g4 ; 4
print :L1 ; L1 has no value
print name? "L1 ; false, L1 is not bound in the current scope