I really like subroutines ... and we should try to used them more!
Most certainly. We're programmers, after all
.
The only problem with them is that you can't have a variable number or arguments ...
I think we're hitting a very low-level design issue of MMA: the parser.
Currently, source lines are split into whitespace separated items (let's call them 'words')
immedeately after reading. This means you cannot write things like (in a sequence)
1.5 0 3-1:$LOUDsince the macro needs to be a word. You cannot write (in the .mmarc)
SetLibPath My Documents/mmaunless you want your stuff in the folders "
My" and "
Documents/mma".
Likewise,
(Am G C) are three words, "
(Am", "
G", and "
C)". You can artificially apply some heuristics on leading and trailing parens but it is clumsy and error prone. The same goes for good old strings, e.g.
print "A B" will print two
words, "
"A" and "
B"" instead of the (more logical) string "
A B".
A
token based parser would be much better. I did some experiments but unfortunately (or maybe fortunately) I lost them... Using a tokenizing parser would have a drastic impact and probably break a lot of songs...