Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-11-02 Thread Dale R. Worley
Oğuz 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

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread L A Walsh
On 2021/10/30 09:07, Robert Elz wrote: oguzismailuy...@gmail.com said: | `break' is not a keyword in the shell, but a special command. That's true. However, 99%**1 of script writers don't see it that way,g they believe it is just like "if" or "while" or "done" or "return". That's

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Ángel
On 2021-10-30 at 23:07 +0700, Robert Elz wrote: > For people who don't believe that all programming languages should work > the same way (usually the same way as the one they learned first) this > isn't necessarily as important - but that's a tiny majority of people. Uh? That's a quite different

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Greg Wooledge
On Sat, Oct 30, 2021 at 08:45:05PM +0300, Oğuz wrote: > I know, it's great. Though I still couldn't figure out how to have a > command run on login and it drives me mad. Depends on *how* you log in.

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Oğuz
On Sat, Oct 30, 2021 at 7:07 PM Robert Elz wrote: > > What POSIX says about this (which you probably know already) is: > > A loop shall enclose a break or continue command if the loop > lexically encloses the command. A loop lexically encloses a > break or continue command

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Oğuz
On Sat, Oct 30, 2021 at 6:55 PM Chet Ramey wrote: > You might be interested in > > https://www.austingroupbugs.net/view.php?id=842 The only argument against dynamic scoping there is that one might use `break 1000' for exiting the outermost lexically enclosing loop and I don't think anyone does

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Robert Elz
What POSIX says about this (which you probably know already) is: A loop shall enclose a break or continue command if the loop lexically encloses the command. A loop lexically encloses a break or continue command if the command is: [and just paraphrasing the conditions]

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Chet Ramey
On 10/30/21 11:02 AM, Oğuz wrote: On Sat, Oct 30, 2021 at 4:50 PM Greg Wooledge 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.

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Alex fxmbsw7 Ratchev
such stuff could be with aliases maybe accomplished, not sure of your req's On Sat, Oct 30, 2021, 17:03 Oğuz wrote: > On Sat, Oct 30, 2021 at 4:50 PM Greg Wooledge wrote: > > As Chet said, it's counterintuitive. Most people don't expect function A > > to be able to affect loops inside

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Oğuz
On Sat, Oct 30, 2021 at 4:50 PM Greg Wooledge 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

Re: Why should `break' and `continue' in functions not break loops running outside of the function?

2021-10-30 Thread Greg Wooledge
On Sat, Oct 30, 2021 at 02:39:19PM +0300, Oğuz wrote: > I found that this behavior had been introduced in 2014, with the > following commit message: > > > set loop_level to 0 > > when entering a function so break and continue in functions don't > > break loops running outside of the function. Fix