Over the past few months I've been gradually grokking why scheme says: (define (f x y z) ..)
and not: (define f (x y z) ..)
The reason: it directly maps the structure of a call to the code it expands to. This mapping is rendered starker when you throw infix into the mix: def (a = b)
..
mac f.x
`(,f ,x)
mac ++n
`(n <- (,n + 1))
# basic type-based dispatch
mac (lhs <- rhs) :case list?.lhs
..
All now legal wart: http://github.com/akkartik/wart/commit/ff999e5258. And I didn't need to make any changes to my reader, just redefine the macros def and mac.--- As I've been playing with infix in recent weeks, I've been idly wondering how far you could push these ideas. Lisper dogma seems to be that only lisp can do macros well because it has parens and homoiconicity. I'm growing to think this is a canard. But if more complex syntaxes can get elegant macros, how much syntax is too much? I speculate that I can build elegant macros into any syntax -- as long as function calls group functions with their args. If I'm right, this is a very valuable insight, and lisp's syntax for defun makes it hard to see. Especially since C programmers like myself can start taking out the space: defun foo(x y z)
..thereby moving farther away from the light[1].The notation f(x) needs to die. [1] I didn't even really focus on this until evanrmurphy brought it up: http://arclanguage.org/item?id=12659 |