4 ms·
> S-Expression is a 1960s hack to simplifiy parsing. S-Expressions were invented as a way to write (externalize), read (internalize) and represent list like da
by lispm 4y ago
> S-Expression is a 1960s hack to simplifiy parsing.
S-Expressions were invented as a way to write (externalize), read (internalize) and represent list like data structures. The original Lisp design had two different syntaxes for code (m-expressions) and data (s-expressions).
It turned out that programs can be represented on top of s-expressions and that simple execution engines and compilers can be written for it.
Further it turned out that one can write user interfaces which in simple ways can read, write, execute s-expressions. Thus s-expressions seem particular useful for interactive programming.
> you just write a+b, in lisp, it's (+ a b)
Lisp does not care much about that, since much of it was to implement tools on top of itself. Thus some of the first systems who could manipulate mathematical formulas were written in Lisp. Much of Lisp is concerned with all kinds of symbolic notations - some use s-expressions, some are not. For example, the first ML was implemented in Lisp and did not use s-expressions. Scheme OTOH also was first implemented in Lisp and did use s-expressions.
Lisp macros and special forms implement syntax on top of s-expressions - what makes it convenient, is that the syntactic extensions are transformation programs written and executed with the same language they extend. That makes it a very powerful and relatively easy to use syntactic extension mechanism - which is widely used in Lisp.
> but it's not effortless, it's far from the language making it easy for you
Some tools need some learning. Once learned, the Lisp user has access to a language which provides a simple and well-integrated syntactic meta-level level.