News for hackers. Stuff that matters.
Re:Compiler basics: Lisp to Assembly by aap_ on Monday November 26, 2018 @02:12AM (#18531668)
Calling this a lisp is a bit of a stretch. S-expressions aren't lisp if they don't have lisp semantics.
Re:Compiler basics: Lisp to Assembly by fao_ on Monday November 26, 2018 @04:44AM (#18532162)
What part of the code that will compile under this simple compiler (i.e. `(+ 2 (+ 3 4))`) _doesn't_ have lisp semantics?
Re:Compiler basics: Lisp to Assembly by samsaga2 on Monday November 26, 2018 @05:01AM (#18532249)
Lisp uses S-expressions but not all the S-expressions are lisp. If you cannot define functions with free variables then is not lisp.
Re:Compiler basics: Lisp to Assembly by kazinator on Monday November 26, 2018 @12:40PM (#18535165)
I would say this:

- tokens are just collections of non-space characters, passed raw through to an assembler, where it is assumed that they denote machine words. Whatever happens, happens. The "symbol" eax will refer to a register, for instance. (If this project had stuck with AT&T assembly syntax, at least that would have been qualified as %eax%).

- functions aren't registered under Lisp symbols but are just global references to assembly-language labels. It seems we can just do (1234 4) and it will just call address 1234.

- no LIS)t P)rocessing to be seen here.

That said, there is no language that is just "Lisp", and so there is no prescribed set of semantics. We can make a prefix expression preprocessor for x86 assembly language and call it "Phil Lisp" (or whatever qualifier).

Re:Compiler basics: Lisp to Assembly by imglorp on Monday November 26, 2018 @06:43AM (#18532611)
Eval... as in REPL, is tough without an interpreter in process.
Re:Compiler basics: Lisp to Assembly by junke on Monday November 26, 2018 @05:49AM (#18532414)
Integer overflow.
Re:Compiler basics: Lisp to Assembly by kazinator on Monday November 26, 2018 @12:40PM (#18535177)
Not all historic dialects of Lisp have bignum integers. I don't know what the current situation is in Emacs Lisp, but it had only fixnums at one point.
Re:Compiler basics: Lisp to Assembly by Bjartr on Monday November 26, 2018 @09:16AM (#18533464)
For those who don't know. What exactly are the semantics of lisp?
Re:Compiler basics: Lisp to Assembly by Jtsummers on Monday November 26, 2018 @09:55AM (#18533711)
This is really a minimal translator from s-exprs to assembly. Which is still an interesting project.

To be a lisp, you need to be able to declare and call functions, and construct and manipulate lists. Once you have that, you can then manipulate the code itself since s-exprs are just lists of a certain construction.