3 ms·
> Actually, no. They're a way of unambiguously representing said AST. I'm not sure how that's a contradiction. "unambiguously representing" is still representi
by devinj 16y ago
> Actually, no. They're a way of unambiguously representing said AST.
I'm not sure how that's a contradiction. "unambiguously representing" is still representing.
> Why do I say that? Because very few people know the full precedence of expressions. So, they break expressions in unnecessary places and/or add redundant parentheses.
Interesting, but not really relevant. They prefer the syntax, knowing that there are things they don't know about it.
> And then there's the problem of manipulating said AST. To do so for a traditional language requires a parser and a bunch of datastructures, which every project reimplements. Everything that you need for lisp is built-in.
Er, I don't understand how you can make that claim. A parser is necessarily built in to any interpreter/compiler for language with syntax, whether that language be a lisp or an assembly language or Java. Some of them don't have the parsers available at all (e.g. C), but some do (e.g. Python), and for some the parser is irrelevant (Lisps, machine code) because the AST (or "AST" perhaps, in the case of machine code) is always directly available regardless of explicitly calling out to the parser. In any case, your claim does not hold for "traditional languages" in any generality, there is too much variety.
- anamax 16y ago> Er, I don't understand how you can make that claim. A parser is necessarily built in to any interpreter/compiler for language with syntax, whether that language be a lisp or an assembly language or Java. The existence of a parser does not imply its availability. As you said "Some of them don't have the parsers available at all (e.g. C)," > but some do (e.g. Python), Python does make a parse tree available, but not in a very useful fashion. You can use it to rewrite programs but not as part of ordinary programming. > In any case, your claim does not hold for "traditional languages" in any generality, there is too much variety. Actually it does because there are very few "traditional languages" that even approach Python's in-language support for their own AST, let alone come close to Lisp's. (Prolog and some of the logic programming languages have some AST support but I wouldn't call them "traditional". I don't remember if APL does.)
- devinj 16y ago> The existence of a parser does not imply its availability. As you said "Some of them don't have the parsers available at all (e.g. C)," No, but it guarantees that, at least in theory, such a parser could be made available. In practice many languages do make it available. Your argument was a general one, that is that all "traditional languages" have this property. > Actually it does because there are very few "traditional languages" that even approach Python's in-language support for their own AST It only takes one counterexample to break a general claim. "Very few" is enough. Nothing about traditional languages has any intrinsic property of being parser and AST-free-- it is merely laziness, minimalism, or coincidence that causes many to not. As examples like Python show, it is quite easy to find a mainstream "traditional language" with a full-blown (actually several full-blown) interfaces to the parser available. Other languages have this too, although examples are not incredibly widespread. Lua has implementations which provide an AST, and even the hyper-traditional language C# has the Expressions framework, which lets you parse/modify/etc. the AST of an expression (including, of course, the new lambdas). It's just not true that Lisp is the only game in town for AST support, nor that "traditional languages" don't have it in general (although it may be true that most do not, this is not the same as claiming that as a group they do not).
- anamax 16y ago> No, but it guarantees that, at least in theory, such a parser could be made available. By that standard, all languages are equivalent. That's true in a rather meaningless sense (Turing equivalence), but very few people think that Haskell is the same as C. > it is merely laziness, minimalism, or coincidence that causes many to not. The reason doesn't matter. If you don't have reasonable "out of the box" support for manipulating ASTs, it isn't part of the language. This cuts both ways - few lisp implementations have reasonable libraries. > It's just not true that Lisp is the only game in town for AST support Feel free to show how ordinary {pick your language} programmers could implement and use something like the LOOP macro. Compare with how easily that can be done in lisp. Ease (like speed) matters.