Hacker News new | past | comments | ask | show | jobs | submit login

From https://en.wikipedia.org/wiki/MUMPS

Since MUMPS interprets source code by context, there is no need for reserved words. You may use the names of language commands as variables, so the following is perfectly legal MUMPS code:

    GREPTHIS()
           NEW SET,NEW,THEN,IF,KILL,QUIT SET IF="KILL",SET="11",KILL="l1",QUIT="RETURN",THEN="KILL"
           IF IF=THEN DO THEN
           QUIT:$QUIT QUIT QUIT ; (quit)
    THEN  IF IF,SET&KILL SET SET=SET+KILL QUIT

    MUMPS can be made more obfuscated by using the contracted operator syntax, as shown in this terse example derived from the example above:

    GREPTHIS()
           N S,N,T,I,K,Q S I="K",S="11",K="l1",Q="R",T="K"
           I I=T D T
           Q:$Q Q Q
    T  I I,S&K S S=S+K Q



Is that actually a grep? Which variable is the string you're grepping?


No, in this context, "grep" is more of a threat than anything.

This snippet just sets a few variables before returning "R" if the function was called in a functional context, or quitting with no value if the caller doesn't expect a value.

Since "K" is a non-truthy, but non-null value, "l1" is never added to S in the T label. "l1" is another non-null-but-false value, so S wouldn't have changed value anyway. The entire thing is just an ugly looking no-op.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: