[Top][All Lists]

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

Re: Why should `break' and `continue' in functions not break loops runni

From: Dale R. Worley
Subject: Re: Why should `break' and `continue' in functions not break loops running outside of the function?
Date: Tue, 02 Nov 2021 22:43:54 -0400

Oğuz <oguzismailuysal@gmail.com> writes:
>> It's a violation of scope.
> It's a violation of lexical scope, I'm asking why not implement
> dynamic scope, what's wrong with it?

Yes ... but the history of programming languages has been the history of
learning that dynamic scoping is dangerous to program and lexical
scoping is the Right Thing.

>> Can you name *any* other language where functions can break out of their
>> caller's loops?  The only thing that comes to mind for me is C's "longjmp",
>> which I've never used even once.  (Not that I do any C programming these
>> days, but back in the 1990s, I did.)

The way to think about longjmp is that it's a goto that wrenches you out
of nested contexts, somewhat like calling a completion in Scheme.  But
if you're using it sanely, it's clear what location the longjmp takes
you to, whereas a dynamically-scoped break is not.


reply via email to

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