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

Re: Scheme mistakes (was Re: nil)

   > > And possibly you should have to write (something like):
   > >
   > >   (throw k v)
   > >
   > > rather than:
   > >
   > >   (k v)
   > >
   > > to invoke a continuation. That's the way that SML/NJ does it.

An advantage to an explicit `throw' special form is that you can throw away
the -old- continuation sooner -- perhaps allowing your program to use less

Consider evaluating:

  (throw (f x) 42)

Since you know that the expression `(f)' must yield a continuation, the
old continuation can be discarded (and perhaps reclaimed by the garbage
collector) -before- you call the function `f'.  If continuations just look
like procedures, then the programmer would have written:

  ((f x) 42)

is which case you don't know that the old continuation is going to be
discarded until -after- the call to `f' returns a continuation.

It is possible to construct crazy examples that run in constant space given
a `throw' keyword and not without.  But I've never seen this matter in