Simon Peyton-Jones <[EMAIL PROTECTED]> wrote:
> You can't really implement C-- on top of C efficiently, because of
> (a) tail calls and (b) the runtime interface for garbage collection,
> exception handling etc.
Agreed. But any practical C-- implementation will start with a C/C++
compiler so that it can get structs and typedefs right, and preferably
also inline functions. It would have to discriminate and reject
"ill-behaved" C constructs.
I was not thinking of implementing C-- "on top of" C; certainly not on
top of ANSI C. But I could imagine a (Perl?) program that translates
C-- into asm-ified C without C function calls. All you'd really need
are a few primitives for getting and setting the sp and ip, a list of
the registers, and some macros for inserting span metadata into a
different linker section. All of this would be straightforwardly
implemented with GCC using a smallish machine-specific header.
I'll bet a non-optimizing version could be produced with no asm - just
use volatile for variables and goto for jumps. Accessing the stack
pointer and inserting span data might require asm.
Best
-John
--
John Tobey, late nite hacker <[EMAIL PROTECTED]>
\\\ ///
]]] With enough bugs, all eyes are shallow. [[[
/// \\\