[Top][All Lists]

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

Re: Procedure proposal: call-with-escape-procedure

From: Marius Vollmer
Subject: Re: Procedure proposal: call-with-escape-procedure
Date: 03 Mar 2001 17:44:53 +0100
User-agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7

Martin Grabmueller <address@hidden> writes:

> I often find an escape procedure useful when writing Scheme code, such
> as for early exits on success, on error or for other reasons.  Since
> `call/cc' is too general (and too expensive in Guile), and using
> `catch' and `throw' is too clumsy for my taste, I tried to find a
> better and generally useful alternative.

Yes, I also think that the interactions between call/cc and
dynamic-wind have not been agreed upon in the Scheme community.

I think it is important to have something like call/ec and tell people
to use it instead of call/cc when they can.  We should maybe even have
`dynamic-unwind' which is like dynamic-wind except that it is an error
to enter or leave it more than once (it would need an `enter' thunk,
then).  Or maybe better, to specify that call/cc does not cause the
`enter' and `leave' thunks of a dynamic-wind to run, but call/ec does.
Or something.

Martin, could you try to summarize what other Scheme implementations
do?  Call/ec (which is actually called
call-with-escaping-continuation, I think) should not really be

I do like the theoretical power of call/cc, but I'm wary of its
practical consequences.  I'd say that few people really take call/cc
into account for every bit of code that they write.  "Can I cope with
this function returning multiple times?  What does my algorithm mean
anyway when it is restarted in the middle?"

Call/ec represents the more common notion of aborting an operation.  I
think it will suffice for a large class of uses of call/cc.  The
larger part of the rest could probably be taken care of by call/1c,
call-with-one-time-continuation, which would construct a continuation
that could be activated at most once, and only when the flow of
control had not yet activated that continuation in the `natural' way.
In other words, call/1c would return exactly once.

Well, please take my comments with a large dose of salt, I have to
think more about this to get the details right and to get a form
opinion.  Thinking about continuations always leaves me dazed.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]