2 ms·
The language being defined here is not a Lisp, it's a (trivial) language that just happens to use (something like) S expressions as the surface syntax. (The re
by lisper 11y ago
The language being defined here is not a Lisp, it's a (trivial) language that just happens to use (something like) S expressions as the surface syntax. (The reason it's only "something like" S expressions is that it has ad-hoc commas to delimit argument lists.)
The characteristic that defines a Lisp is that code is not a sequence of characters, it's a data structure -- typically a tree of cons cells -- which can be manipulated within the language itself. The language being defined here doesn't have that property.
It is this property that allows you to write macros, which is what makes Lisp cool. Without it you don't have Lisp, you just have a run-of-the-mill programming language with weird syntax.
- jhedwards 11y agoYou make an interesting and important point, but to be honest the article's intended audience is people who are intimidated by language translation or just have never done it before. The "Minilisp" is not really a language so much as a tool to demonstrate the concepts of tokenizing, parsing and recursion. It is unfortunate if the result is a mischaracterization of real Lisp, but I was trying to cut a balance between being accurate and filling the article with tangential information.
- lisper 11y agoThat's a fine goal, but there's more at stake here than mere "accuracy". When you design a language that uses S-expression syntax (sort of) and has "Lisp" in its name, but eliminates the reason for using S-expressions, you're not really laying a foundation for understanding, you're creating a cargo cult (https://en.wikipedia.org/wiki/Cargo_cult https://en.wikipedia.org/wiki/Cargo_cult, specifically https://en.wikipedia.org/wiki/Cargo_cult#Metaphorical_uses_of_the_term https://en.wikipedia.org/wiki/Cargo_cult#Metaphorical_uses_o...)
- junke 11y agoTo expand a little on this, the article shows the parsed AST: { type: 'function', value: 'defn', children: [ { type: 'function_name', value: 'average' }, { type: 'arguments', children: [ { value: 'x' }, { value: 'y'} ] }, { type: 'function', value: '/', children: [...] } ] } The parenthesis-based surface syntax is directly translated into the above, which is IMO more verbose and contains no additional information. On the other hand, it is valid Javascript data. So it looks like it is equivalent to manipulate the above form. Now, suppose you want to define a function which returns a form which performs a function call. We won't use macros, but simply a function that builds an AST. We can't write Javascript directly with this parser, so let's say there are primitive Lispy functions to build equivalent javascript trees: (defn my-funcall () (js%hash (js%kv "type" "function") (js%kv "value" "my-fn") (js%kv "children" (js%vector (js%hash (js%kv "value" 3)))))) ... whereas, a lisp-based approach would be: (defn my-function (list 'my-fun 3))