Re:Reader Macros in Common Lisp (2014)
by moonchild on Sunday November 20, 2022 @07:25AM
(#33680393)
Why a reader macro? Just use s-expressions, like sbcl and ccl.
Re:Reader Macros in Common Lisp (2014)
by guenthert on Sunday November 20, 2022 @02:07PM
(#33684095)
Indeed. That would ease making other tools, e.g. a super-optimizer, which generate or modify assembly code.
1970's calling. Been there. Done that: https://news.ycombinator.com/item?id=33517092#33517797
Thanks for the inspiration. The fact that you've already done it won't stop me.
Got more details/links to study?
https://github.com/timonoko/nokolisp_addons/blob/master/asse...
Keyword is the line
(dos-eval '(debug < TO.DEB > NUL))
("mapc" and "map" had their parameters in wrong order, which annoys me even today)
Re:Reader Macros in Common Lisp (2014)
by macoovacany on Sunday November 20, 2022 @07:09AM
(#33680308)
I’m guessing #ASM does the assembly at read or load time?
Does it desugar to something like this?
(assemble ‘((mov rax %x) (add rax 1)))
Anyhow I think this is a great project. I hope you share it! I’ve often thought bootstrapping an assembler with lisp macros would be an interesting way to build a compiler from the very ground up. Assembler macros are nothing new, but I’ve never heard of an homoiconic implementation.The original LISP's "Lisp Assembly Program" was rather like this -- see Appendix C in the Lisp 1.5 manual, from 1962: https://www.softwarepreservation.org/projects/LISP/book/LISP...
Out of curiosity, why not write a Scheme or Common Lisp compiler? Or just a subset?
I want an operating system from first principles. To write the smallest OS with the smallest language and the least amount of restriction.
The goal is being able to replace every single part of the runtime/interpreter if you wish, but the OS itself starts with the fewest functions/features possible. cons, lambda, and the other usual suspects, a way of running actual native machine code, the homoiconicity of LISP, a runtime-editable image, packed into a UEFI binary.
You could build yourself a Scheme or a Common Lisp on top of it if you wish.
> You could build yourself a Scheme or a Common Lisp on top of it if you wish.
No offense, but if it were Common Lisp I would take a look, but I don't have much interest in learning a one off language.
Sounds like you're having so fun, though, so good luck!
My goal is to create the barest-metal Lisp OS (basically Lisp REPL with full ring-0 access, the OS) with an asm reader macro to write low level assembly opcodes you can jmp into.
(Just thought of this syntax on the spot, I'm a few dozen hours away from that still.)