[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: Alex fxmbsw7 Ratchev
Subject: Re: Why should `break' and `continue' in functions not break loops running outside of the function?
Date: Sat, 30 Oct 2021 17:04:48 +0200

such stuff could be with aliases maybe accomplished, not sure of your req's

On Sat, Oct 30, 2021, 17:03 Oğuz <oguzismailuysal@gmail.com> wrote:

> On Sat, Oct 30, 2021 at 4:50 PM Greg Wooledge <greg@wooledge.org> wrote:
> > As Chet said, it's counterintuitive.  Most people don't expect function A
> > to be able to affect loops inside function B.
> I do, and a subshell can prevent function A from affecting loops
> inside function B. But that is not a real problem, you wouldn't call,
> say `break 3', when you're only 2 loop levels deep in a function
> unless you wanted to exit from the loop from within the function is
> called after returning.
> > 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?
> >
> > 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.)
> As far as I know `longjmp' is far more advanced than shell's
> break/continue. I can't name another language, but netbsd sh, busybox
> sh, and zsh are shells that implement dynamically scoped break and
> continue.
> >
> > What are you actually trying to do?
> >
> Nothing. Idle curiosity.

reply via email to

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