This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ANN: Schelab or numerics for Scheme -- prototype



> On the subject, the way that C uses the stack for local variables
> is a very powerful and efficient system. In guile the local variables
> within a let or a function are stored in much the same way as other
> variables which implies that every time you enter a (let) and have
> a bunch of variables declared, you generate a bunch of garbage even
> though you know that they are only temporary variables.
> 
> Very clever use of recursion and `functional programming' often
> eliminates the need for let but leads to some mind-bending code
> (and still the function argument bindings will surely generate garbage too).
> Is there a way for scheme to make more effective use of the stack?
> Would this spoil the clean structure of the language?
> Even if it introduced the same hole that C suffers (i.e. return()ing
> a pointer to the stack and having the contents clobbered)
> I for one would be willing to wear that.
> 
> Have I got the right idea of what is going on here or has this issue
> already been taken care of?

Yes, you've got generally the right idea about how Guile handles local
variables.  SCM has some hacks to improve that, but even so it's not
as good as it could be.  A little more analysis would allow us to keep
much more on the stack --- even a simple bytecode compiler would help
with this.  Beyond that, people have published lots of research on
analyses that help you turn flying closures into normal code, which
helps too.