This is the mail archive of the guile@sources.redhat.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: How often are continuations created?


Telford Tendys <telford@eng.uts.edu.au> writes:

> In effect you are saying that the stack-copying algorithm only needs to
> copy data and not control but if a continuation exists in a global variable
> then there is no reason why that same continuation could not be invoked
> many times over (yeah, I realise that the result is a program of minimal
> sanity but that is beside the point).

Sorry, I needed more explanation.  I allocates all local variables
in frames, which are on the control stack.  All shared variables
(which I call external variables) are allocated separately.  So, there
is no variable on the data stack. (Probably I should call it differently.)
You can call the same continuation as many as you want.

> The other point that I would like to make is that a typical subroutine
> call would have about three parameters (I haven't measured this, I'm just
> pulling the value out of my head) so for each one return address there are
> three data pointers which make the data stack bigger than the control
> stack. Then there are local variables and so on...

I'm going to move all parameters from the data stack to a frame before
calling a procedure.  There is a more efficient way, but I guess this
is enough efficient.  (Hmm, is this significant?)

> I would estimate that most of the bulk will be in the data stack
> which you are still copying. What makes you think the data stack will
> be insignificant?

I'll use the data stack only temporarily.  There will be no data unless
you create a continuation like this:

  (define (foo)
    (+ 1 (* 2 (call/cc ...))))

In this case, there are 1 and 2 on the stack.  If you do it like the
following, there will be nothing on the data stack:

  (define (foo)
    (let ((value (call/cc ...)))
      (+ 1 (* 2 value))))

because call/cc is called before the computation of (+ 1 (* 2 ...)).
(Maybe the compiler should take care of this.)

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