4 ms·
This line in MUMPS is not only valid, it also actually does something potentially useful: s:foo'="" foo(foo)=foo It's actually a bit tricky to explain wha
by roywiggins 13y ago
This line in MUMPS is not only valid, it also actually does something potentially useful:
s:foo'="" foo(foo)=foo
It's actually a bit tricky to explain what it does. Everything in MUMPS is effectively a tree. Each tree has a value in the "root node" and you can set it like this:
set foo="hello"
You can also put data deeper into the tree:
set foo("fizz")="buzz"
So if something is passed to you and you want to know if you can treat it as a string, you test to see if it's a null string:
if foo'="" do [something]
('= means !=)
Two more features: 1) Almost every directive can be reduced to one letter. 2) If I want to quit based on a condition, I can do either
if condition quit
or
quit:condition
So the line above is more legibly written as
if foo'="" set foo(foo)=foo
So if foo="bar", it's equivalent to:
set foo("bar")="bar"