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

Re: break/continue vs. try-always



On Fri, 6 Jun 2014 14:08:53 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jun 6, 2014 2:04 PM, "Peter Stephenson" <p.w.stephenson@xxxxxxxxxxxx>
> wrote:
> >
> > We could do something like add "break -r" to reset.  It would only be
> > usable in always blocks (not sure about traps) because otherwise you
> > don't get the chance to execute it.
> 
> I was thinking perhaps "break 0" which is otherwise/currently an error.
> Assuming the break handler can tell when it is in the scope of an always
> block.

That's straightforward --- well, it isn't, but it's straightforward to
make it only work in always blocks and ignore it elsewhere which is
probably good enough since this is rather a specialised feature --- but
it occurred to me that for a complete sandbox it would be useful to have
"continue -r" and "return -r".  "continue 0" works but obviously "return
0" doesn't do that.  Actually, break -r (or break 0) would have a side
effect on continue because of the interaction between the "breaks" and
"contflag" variables, so arguably break -r and continue -r shouldn't be
independent however it's implemented.

pws



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