Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: break/continue vs. try-always



On Sun, 8 Jun 2014 20:43:58 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> If you like the idea of function scope as a sandbox, it seems me that a
> neater way to handle this would be to add an option to force break and
> continue to respect function scope.  Then no new syntax is required.
> Provide you define that the new option (call it localloops for now) is
> applied in the outer function on return from the inner, you can do
> everything with
> 
> 
> setopt localoptions localloops
> () {
>    # call user code
> }
> # localloops is restored on return here and used to cancel breaks /
> # contflag before resuming user code at this point.

A further thought is we could even flag an error if there was a break or
continue pending at this point, since evidently the user tried to do
something they shouldn't.  Then we could get the continue-outside-a-loop
test to work, thought it wouldn't quite be testing the code it was meant
to test.

pws



Messages sorted by: Reverse Date, Date, Thread, Author