Better HN
topnewbestaskshowjobs
Log inSign up

ijoker

3 karma · joined Mar 14, 2017 (9y ago) · 1 submissions

Submissions

comment 9y ago · link · parent

Another thing that's really weird about MUMPS is that variables are dynamically scoped. So this bit of code prints 5:

  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.