Misc ideas & comments
Harvey J. Stein
30 Mar 1998 18:50:39 +0300
firstname.lastname@example.org (Matthias Hoelzl tc) writes:
> 1) As far as I can see there is no simple way to generate tail
> calls in the front end. Gcc does some tail call elimination in the
> back end, but not enough to be satisfying for a Scheme compiler (as far
> as I can figure out it only optimizes self-tail-calls).
It's not too hard if one's willing to use a different calling
paradigm. I think that in C the caller sets up the stack, calls the
routine, & cleans up the stack. If instead the called rtn were to
clean up then it'd be easy to generate full tail-recursive code. When
the caller is going to call a subroutine and just return the
subroutine's return value, it could just replace its stack frame with
the subroutine's stack frame and jump to the subroutine instead of
calling the subroutine. You might also want to add a size into the
stack to make it a little safer.
Stallman had some ideas and interest regarding this. Doing it would
allow more straight forward conversion of Scheme to C while preserving
> I will investigate these points some more and then ask the people on
> the egcs mailing list whether I am on the right track and whether they
> would be willing to help with such an undertaking, however I am a bit
> sceptical. Answering my (undoubtedly many) question about the gcc
> back end would mean spending a lot of their time to help with a scheme
> front end to gcc and I suppose they are more interested in improving C
> and Fortran, since these are the languages they actually use
> themselves. Furthermore I am not really certain whether I want to
> spend that many hours writing a compiler that nobody will be
> interested in anyway. I'll keep you updated about the results of my
> inquiry and my future plans if you are interested.
I'd encourage this. My impression is that the egcs people would be
happy to have another front end integrated into the source tree.
There's work on Ada and maybe even Pascal, as well as C & Fortran.
> Some Scheme interpreters (elk) seem to be able to get quite far with
> dlopen, I don't know whether it is flexible enough for all needs.
> However I mainly want a Lisp system that allows me to develop fast and
> small stand-alone-applications with easy integration with C/C++
> libraries (currently I can either get fast and large by using a Common
> Lisp system, or small and slow by using Scheme); I realize that I am
> quite alone with this in the Lisp community. For my aims a batch
> compiler where I can link in an interpreter to do the development work
> and as a scripting language would be good enough.
You're not alone. I'd like it too.
Harvey J. Stein
Berger Financial Research