by ijoker · 9y ago · 0 comments
foo() ; declare function foo
n x ; declare variable x
s x=1 ; set x to 1
d bar() ; call bar
w x ; print x
q ; return
bar()
s x=5 ; set x to 5. Since x is not declared in this function's scope, it will search the symbol table of the calling function and overwrite its x
q
I've run into so many bugs caused by something like this.I'm actually kinda used to that; I grew up with BBC Basic, which behaves the same way:
10 i = 0
20 PROCtest1
30 END
40 :
50 DEF PROCtest1
60 LOCAL i
70 i = 1
80 PROCtest2
90 ENDPROC
100 :
110 DEF PROCtest2
120 PRINT i
130 ENDPROC
> RUN
1
...it occurs to me that BBC Basic, at least the later versions with block IFs, is a better language than Mumps in almost every way (except the integrated database stuff)!