5 ms·
> I can't say that I love the sheer number of parentheses required by the language. Come up with a better way of representing an Abstract Syntax Tree in text,
by DannoHung 16y ago
> I can't say that I love the sheer number of parentheses required by the language.
Come up with a better way of representing an Abstract Syntax Tree in text, please.
> However, the code is data idea seems genius to me.
You know, I think that the reluctance to use functions as values in programming by some of the early luminaries is that functions as values in Mathematics just isn't considered as "normal" outside of fields concerned with the fundamental basis of mathematics. Since the computer itself doesn't need to be described nor does it necessarily benefit from those terms, it doesn't immediately take hold that programs running on computers are a lot easier to reason about once you've got functions being treated as values.
I mean, take differentiation and integration: fundamentally, those are two functions that you can run on another function to get a third function as a result. Does it ever actually get taught that way? I mean, is the implication of that really remarked upon? You go over the fundamental theorem of calculus in about twenty minutes in the first introduction to it, and then bam, here's all the shortcuts for differentiating. No reflection on just what the implications of that are.
- corruption 16y agoCould you go into your interpretations of the implications?
- DannoHung 16y agoI am ill equipped to express it eloquently, unfortunately. But in poor words, it means that we can find unification between fields of mathematical thought. Taking ideas from one area, finding ways to regularly manipulate them, and then applying them in a novel way. Being able to find parallels between unrelated work because they are similar in how they are transformed. Abstract algebra is the subject dedicated to that notion in general, category theory the one that, it would seem, is explicitly dedicated so.
- devinj 16y ago> Come up with a better way of representing an Abstract Syntax Tree in text, please. If in programming what we're really doing is telling the compiler stuff, and the compiler only sees an abstract syntax tree, traditional syntaxes are a way of representing an AST in text, and commonly considered to be "better" by the particular language's adherents (Ruby programmers like Ruby syntax, Java programmers like Java syntax, etc.). Sure, you don't get to apply proper macros, but Java/Ruby/etc. programmers don't care about that. What representation is "better" really boils down to taste and opinion.
- DannoHung 16y agoI think you're focusing on the wrong part of Abstract Syntax Tree. Lisp, fundamentally, has no syntax. It's just trees. That's the crux of how you write it. When fleitz said that he doesn't like the parens, I was just commenting, perhaps in too pithy a fashion, that the parentheses are incidental to the language. A vessel to hold the substance, as a glass holds water, if you will.
- deleted 16y ago[deleted]
- devinj 16y agoI see what you mean. But I don't think that's what he meant by Lisp. After all, if you believe that, then Python is a Lisp too[1]. And when people say "Lisp", they don't mean "Scheme and CL and [...] and Python". Sure, like any class of languages, there is not a single syntax. But every lisp has a syntax. And the languages people associate with the class "Lisp" use parens. And in many peoples' opinions, there are better ways of representing an AST. Like indentation, for example. Or curly brackets. 1: http://norvig.com/python-lisp.html http://norvig.com/python-lisp.html
- shaunxcode 16y agoDylan is worth taking a look at to consider what lisp sans parens might look like. http://en.wikipedia.org/wiki/Dylan_%28programming_language%29 http://en.wikipedia.org/wiki/Dylan_%28programming_language%2...
- DannoHung 16y agoYou'll notice that in the first paragraph there, he says: > Python supports all of Lisp's essential features except macros, and you don't miss macros all that much because it does have eval, and operator overloading, and regular expression parsing, so some--but not all--of the use cases for macros are covered. Macros are a huge part of Lisp. Were they not, I don't think you'd see Lisp programmers defending the bare bones not-syntax so fiercely. For what it's worth, if you get good at a language, you start decomposing things into trees yourself when you're faced with some tricky code.
- tzs 16y ago"Come up with a better way of representing an Abstract Syntax Tree in text, please" You could use type size, with operators one point larger than their operands. The nice thing is that this would discourage nesting things too deeply.
- rdtsc 16y ago> Come up with a better way of representing an Abstract Syntax Tree in text, please. Perhaps you could use indentation like Python or YAML, for example?
- plorkyeran 16y agoWhile a cute idea, I suspect the sheer number of newlines required would make it hard to read. Even a simple compound statement like (+ (* x y) (* z w)) would require at least three lines.
- astine 16y agoThere is at least one attempt at this called 'Sweet Expressions' still floating out on the web somewhere. It got horribly ripped by the c.l.l community. Personally, I don't see that it adds anything to the language but ambiguity. It's worth looking, however, at if you are interested in alternative syntaxes for Lisp.
- philh 16y ago> functions as values in Mathematics just isn't considered as "normal" outside of fields concerned with the fundamental basis of mathematics. It seems to be fairly common in linear algebra. The usual way to represent a linear function is as a matrix, and a function on that matrix is a function on a function. You also get fields of polynomials, in which differentiation is a linear operator.