Lisp without garbage collector for low level programming

Is there a Lisp dialect that has Lisp semantics and low C manipulation? Something like getting an arbitrary memory address (virtual or physical memory) and doing something with it; pointer to hardware device ...

For example:

(defvar a '(1 2 3 4)) ;; I have a list (defvar b (cdr a)) ;; b is the cdr of a. But I want b to ;; actually refer to the tail of a (setf b '(4 5 6)) ;; b now has new value, but a remains unchanged 

I want to use Lisp to express low-level problems. For example, how can I control individual bytes and bits when running Lisp on bare metal? In C, I can get a pointer and do pointer arithmetic to point to whatever I want in memory space (virtual or physical). The pointer can also point to devices and arbitrary addresses by the equipment designer.

Why do I need it? Well, I want to learn how to use Lisp with low-level programming. Ultimately, I want to write a simple OS for learning, but in Lisp. I will write one in C, as well as for an initial understanding, but if I can only write in C, how can I be sure and say that I understand how to implement the OS? I think I only really understand how to implement the OS, if I can write it in a language other than C to make sure.

I do not want to write something like the C kernel for the OS and Lisp for everything else.

+7
garbage-collection lisp
source share
4 answers

As I mentioned in my comment, most Lisp implementations can do this. Generic Lisp already has all kinds of bit calculation functions. All implementations provide interfaces for low-level operations.

In Lisp, you can write web servers, compilers, window managers, etc. Many Lisp systems are written in Lisp and, therefore, primitives are needed to write / read to / from memory.

You just need to run some implementation of Lisp and read the manual. All of this is documented.

For example, see compatibility level CFFI (Common Foreign Function Interface), chapter pointers . CFFI is working on several Common Lisp implementations.

+5
source share

There was an old project that you might be interested in:

Introduction

Movitz aims to be an ANSI Common Lisp implementation that targets the ubiquitous x86 PC architecture on metal. What works without any operating system or other form of software Environment. Movitz is a platform for developing kernel operating systems, embedded and single-purpose applications. You can potentially create several completely different operating systems using Movitz.

Movitz: Lisp x86 Common Development Platform

+4
source share

You can watch PreScheme:

http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.4031

Pre-Scheme is a statically typed dialect of the Scheme that gives the programmer efficiency and low access to C machines, while retaining many of the desired features of the Scheme. The PreScheme compiler uses type, output, and schema and Lisp compiler methods to compile problematic Schema functions, such as closures, into C code without significant time consuming. The use of such functions in Pre-Scheme programs is limited to those cases that can be compiled into efficient code. Type reconstruction is performed using a modified Hindley / Milner algorithm that allows user functions to be overloaded. All top-level forms in Pre-Scheme programs are evaluated at compile time, which gives the user additional control over the partial evaluation of the program compiler. Pre-Scheme was implemented and is used to write byte code and associated support code to fully implement the scheme.

I think Scheme48 is still using PreScheme in its implementation: http://s48.org/

+4
source share

You either create or modify an existing Lisp language with low-leverage tools and APIs that you should run Lisp without a kernel or user space, and cross-compile this for blob that is not related to anything (static). SBCL can be loaded using someone else's CL implementation and even cross-compiled, so if you want CL to start reading code and articles about SBCL, as well as the design of the operating system.

How you go from there depends on who you want. Running Lisp can theoretically have all the resources, and you can do all your applications and support there. You even have a garbage collector for the lowest level of your OS :)

Ultimately, you'll need the ability to easily connect regular applications and device drivers. Thus, you can sail through other efforts. Imagine you had to write your own browser or nvidia driver from scratch.

+3
source share

All Articles