Sunday, December 12, 2010

M Language Tutorial - The cryptic style

In order to save typing at cost of readability, every command and built in function of M has abbreviation/shortcut.
The following examples are perfectly valid
f i=1:1:9 s sqtable(i)=i*i; 'f' stand for 'for' and 's' for 'set'
s i="" f  s i=$o(sqltable(i)) q:i=""  w i," ",sqltable(i),!;'q' stand for 'quit' '$o' for '$order', 'w' for 'write'
As we spend most of our time reading code written by others, modern programming style does care much about naming thing. The abbreviated style of most if M code is really pain especially for novices.