How does one implement protected memory model and POSIX on top of SBCL? Through array of 32bit numbers? CFFI could be used, but compilation to CFFI leads of segfaults, exploits and breaks ability to easily access data of running C/C++ program.
I still want to compile C/C++ code for SED and GREP into Lisp.
Name:
Anonymous2013-06-02 13:43
>>1
you are going to have trouble if there's pointer arithmetic.
Trying to translate a lower level language to higher level language is called decompilation, and it won't work 100% because the lower level language is far more expressive, there are things that you just can't do in the higher level one.
That said, it's still possible in many cases to do it. Arbitrary pointer arithmetic is out but if you can associate each pointer with what it points to (and how large that object is) then you can reverse that into array indices. Undefined behaviour like moving a pointer off either end of an object so it points nowhere defined is of course not decompilable.
Also, you'll end up with C-style Lisp, which may not be exactly what you had in mind...