On 10/5/06, Marcin 'Qrczak' Kowalczyk <qrczak_at_knm.org.pl> wrote:
> Michael Sperber <sperber_at_informatik.uni-tuebingen.de> writes:
>
> >> For example a parser of script parameters might exit this way when it
> >> recognizes --help or --version, to leave the normal control flow for
> >> the normal usage of the program.
> >
> > For that purpose, Scheme has call/cc. The exception mechanism is for
> > exceptional situations.
>
> What is an advantage of call/cc over a condition here?
An exit operation based on exceptions could be caught and potentially
mishandled by intermediate exception handlers between the call to exit
and the top level of the program. It is also misleading to
programmers to treat completion of the program as an "exceptional"
situation; program termination is a normal occurrence and not a
problem to be dealt with exceptionally.
An exit operation based on call/cc directly produces a final result at
the end of a program; it cannot be intercepted (heavy-handed tools
like dynamic-wind notwithstanding) and does not imply anything other
than normal flow control.
--
Carl Eastlund
Received on Thu Oct 05 2006 - 16:02:27 UTC