[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]

    Another possiblity would be to support some sort of compile-to-C strategy,
    or to directly hook into the gcc backend.

I don't think it would work well to try to hook into GCC directly.  
Mixing a C program with a Lisp program is cumbersome.  I think it
would be much cleaner to use GCC itself.  

I think it would be possible to define a limited set of cases in
which GCC could handle tail recursion.  For example, suppose there
is a way to declare a function type as tail-recursive.  Then it
would be called with a different calling sequence.  All callers
would need to have a declaration saying that the function being
called is tail-recursive, so they could use the special calling
sequence.  This calling sequence would be designed to make tail
recursion straightforward to implement.

Then all the C code produced from Lisp would have the proper declarations
so that tail recursion would work in compiled Lisp code.  Thus, you would
not need to do any explicit continuation passing in the compiler from Lisp
to C.  It could be almost a toy compiler.

I will take care of implementing the tail recursion declaration feature
in GCC, for all machines, if somebody can supply a suitable portable
spec for what kind of calling convention to use.

What do you think?