3 ms·
Frankly, I don't think you "get" Lisp at all. Lisp's lack of syntax is its greatest strength. Beginning or inexperienced programmers in general seem to have g
by logjam 19y ago
Frankly, I don't think you "get" Lisp at all. Lisp's lack of syntax is its greatest strength. Beginning or inexperienced programmers in general seem to have great difficulty with this concept.
> Even defined down to "true macros", this is simply folk wisdom: you can get "Lisp-style macros" out of any language that gives you access to an abstract syntax tree.
Here's what Norvig says about a particular language that has access to the AST (he's not a "convert" to Python - he just decided to use it for examples in his AI book because he feels beginning programmers can pick it up easier):
Python does not have macros. Python does have access to the abstract syntax tree of programs, but this is not for the faint of heart. On the plus side, the modules are easy to understand, and with five minutes and five lines of code I was able to get this:
>>> parse("2 + 2")
['eval_input', ['testlist', ['test', ['and_test', ['not_test', ['comparison',
['expr', ['xor_expr', ['and_expr', ['shift_expr', ['arith_expr', ['term',
['factor', ['power', ['atom', [2, '2']]]]], [14, '+'], ['term', ['factor',
['power', ['atom', [2, '2']]]]]]]]]]]]]]], [4, ''], [0, '']]
This was rather a disapointment to me. The Lisp parse of the equivalent expression is (+ 2 2). It seems that only a real expert would want to manipulate Python parse trees, whereas Lisp parse trees are simple for anyone to use.
- pchristensen 19y agoNorvig didn't convert to Python, Python converted to Peter Norvig!