Lisp syntax target for AST model

Lisp Syntax is an AST, as far as I know, but in a high-level format to allow a person to easily read and modify, while at the same time facilitating processing and source code.

For this reason, Lisp says that code is data, and data is code, because code (s-epxression) is just AST. We can connect more ACTs (which are our data, which are just lisp code), to other ACTs (lisp code) or independently to expand its functionality and manage it on the fly (run time) without having to recompile the whole OS to integrate new code . In other languages, we must recompile to turn the source code into human language into a valid AST before it can be compiled into code.

Is this the reason that lisp syntax needs to be designed as it is (it is an AST, but it is human readable to satisfy both the human and the machine) in the first place? To provide stronger (on the fly - runtime), as well as simpler (not recompile, faster) communication between the human machine?

I heard that the lisp machine has only one address space that contains all the data. On an operating system such as Linux, programmers only have a virtual address space and pretend to be a real physical address space and can do whatever they want. Linux data and code are separated by areas because effectively data is data and data is code. In a regular OS written in C (or C), it would be very dirty if we used only one address space for the entire system, and mixing data with the code would be very dirty.

In a lisp machine, since code is data and data is code, is this the reason that it has only one address space (without a virtual layer)? Since we have a GC and no pointer, should it be safe to work with physical memory without breaking it (since only one single space is much more complicated)?

EDIT: I am asking about this because it is said that one of the advantages of lisp is its one address space:

Safe language means a reliable environment without the need for individual tasks to go out into their own separate memory spaces.

The Unix-specific โ€œprocess-separated modelโ€ has significant advantages when working with software that may be unreliable for a point of insecurity, as in the case of code written in C or C ++, where invalid pointer access can โ€œdelete the systemโ€ . MS-DOS and its descendants are very unreliable in this sense, where simply about any program error can lead to a decrease in the entire system; Blue Screen of Death, etc.

If the whole system is built and encoded in Lisp, the system will be like a lisp environment. This is usually quite safe, because once you get to the standards that correspond to the layers, they are completely reliable and do not offer direct access to pointers, which would allow the system to self-destruct.

The Third Law of Intelligent Personal Computing

Volatile storage devices (i.e., RAM) should be used exclusively as a read / write cache for non-volatile storage devices. From the perspective of all software, except for the operating system, the machine should represent one address space, which can be considered non-volatile. No computer system complies with this law, which takes more time to fully recover from a violation of its power source than an electric lamp.

A single address space, as indicated, contains all running processes in the same memory space. I'm just wondering why people insist that one address space is better. I associate it with AST as Lisp syntax to try to explain how it fits a single-space model.

+4
source share
1 answer

Your question does not reflect reality very accurately, especially regarding the separation of code / data in Linux and other OSs. In fact, this separation is not performed at the OS level, but by the compiler / program loader. At the OS level, there are only memory pages that can have different protection bits (for example, executable, read-only, etc.), and above this level there are various executable formats (for example, ELF on Linux) that define restrictions for different parts of the program memory.

Returning to Lisp, as far as I know, historically, the S-expression format was used by the creators of Lisp because they wanted to focus on the semantics of the language, postponing the syntax for some time. There was a plan to eventually create some syntax for Lisp (see M-expressions), and there were some Lisp-based languages โ€‹โ€‹that had another syntax, like Dylan. But overall, the Lisp community has come to a consensus that the benefits of S-expressions reduce their weaknesses, so they are stuck.

As for code as data, this is not strictly related to S-expressions, since other code can also be considered as data. This whole approach is called metaprogramming and is supported at different levels and with different mechanisms in many languages. Each language that supports eval (Perl, JavaScript, Python) allows you to process code as data, just a view is almost always a string, and in Lisp it is a tree that is much more convenient and easier, such as macros.

+5
source

All Articles