4 ms·
S-expressions are just the lowest common denominator of programming language syntax and more generally trees (aka lists of atoms and lists). The idea is that a
by CamTin 8y ago
S-expressions are just the lowest common denominator of programming language syntax and more generally trees (aka lists of atoms and lists).
The idea is that all program listings are essentially just lists of things, including other lists: A Javascript source file can be thought of as a list of lines, or more semantically a list of statements and expressions. Function calls are just the name of a function and a list of arguments. Each different kind of statement or expression has its own kind of syntax: a `function(baz) { yadda(baz); }' expression uses different syntax than a `if (something) { yadda(foo); } else { blah(bar); }' statement. S-expression languages just use one kind of syntax for everything, so you can do `(lambda (baz) (yadda baz))' and `(if something (yadda foo) (blah bar))' instead.
This uniformity of syntax allows most of the interesting features of lisps, like that everything is an expression (returns a value), and macros, which are kind of a souped-up version of C preprocessor `#define's.
- galfarragem 8y agoA great explanation. It's a pity that is buried in the thread.