4 ms·
Because Lisp uses a flexible representation, the representation has to be validated to see that it conforms to a given syntax (such as that of Lisp source). Thi
by kazinator 7y ago
Because Lisp uses a flexible representation, the representation has to be validated to see that it conforms to a given syntax (such as that of Lisp source). This can happen naturally in a code-expanding tree walk. The subsequent structure can then be processed without additional validation; every form has the right kinds of pieces in the right positions. If (1 a) or ((a) b) are not valid forms, their presence can be diagnosed at that stage. Subsequent processing stages, can trust that the pieces are where they are supposed to be. The invalid forms like (1 a) and ((a) b) are assumed not to occur, just like any bad inputs to a module that have been checked away.
You're arguing for a definition of AST that basically coincides with "decorated AST": AST plus some semantic attributes, and that a generalized tree form that encodes supersets of a syntax cannot be an AST.
- lispm 7y ago> This can happen naturally in a code-expanding tree walk just because something can be interpreted as a tree, it's not suddenly an Abstract Syntax Tree. It's mainly nothing more than a hierarchical tokenizer format. A flexibility of the Lisp source representation comes because it is NOT an AST and thus not bound to a particular correctly represented syntax. A macro for example can turn any wild combination of tokens into more wild combination of tokens - regardless of what the symbols/numbers/lists/strings, ... actually might 'mean'.