zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: break/continue vs. try-always
Date: Fri, 13 Jun 2014 10:55:07 +0100	[thread overview]
Message-ID: <20140613105507.7d11572e@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <140612235757.ZM4782@torch.brasslantern.com>

On Thu, 12 Jun 2014 23:57:57 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:

> On Jun 12,  8:35pm, Peter Stephenson wrote:
> }
> } This makes a break or continue at the end of a function produce a
> } warning.  It didn't seem worth a hard error, but presumably a break or
> } continue is usually intended to do something so it should be reported if
> } it doesn't.
> 
> Hrm.  That makes it sort of like WARN_CREATE_GLOBAL.  I can think of
> cases where you want the warning, and cases where you don't ... the
> situation that got us to this point is one of latter.

I agree there's no obvious single right answer.  In the test code, we
can handle the warning when it appears, however: it's inside any
redirection of test output.

> } +When this option is not set, the effect of tt(break) and tt(continue)
> } +commands may propagate outside function scope, affecting loops in
> } +calling functions.  When this option is not set, a tt(break) or
> } +a tt(continue) that is not caught within a function produces a warning.
> 
> Typo, extra "not" in the last sentence.

Yes, and I improved the documentation after I'd sent the patch to make it
clearer what happens where.

> } +	opts[LOCALLOOPS] = saveopts[LOCALLOOPS];
> } +    }
> } +
> } +    if (opts[LOCALLOOPS]) {
> } +	if (contflag)
> } +	    zwarn("`continue' active at end of function scope");
> } +	if (breaks)
> } +	    zwarn("`break' active at end of function scope");
> } +	contflag = breaks = 0;
> 
> Since breaks is saved as obreaks on entry to doshfunc, shouldn't this be
> 
> 	breaks = obreaks;
> 
> Also, probably need to save/restore contflag and loops?  In case the
> function is called from a trap handler, for example?

As this is a new feature anyway, there's no reason we shouldn't do
that.  I couldn't think of a case where the continue or break wouldn't
already have been dealt with if they were set; traps do the saving and
restoring of stuff elsewhere.  But for a couple of extra variables it seems
a reasonable piece of safety.

pws


      reply	other threads:[~2014-06-13 10:05 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-04  2:12 Oddball output from zerrmsg() Bart Schaefer
2014-06-05  5:37 ` [PATCH] " Bart Schaefer
2014-06-05 15:53   ` break/continue vs. try-always Bart Schaefer
2014-06-06 20:58     ` Peter Stephenson
2014-06-06 21:08       ` Bart Schaefer
2014-06-06 21:45         ` Peter Stephenson
2014-06-07  6:22           ` Bart Schaefer
2014-06-08 17:54             ` Peter Stephenson
2014-06-08 18:41               ` Bart Schaefer
2014-06-08 19:43                 ` Peter Stephenson
2014-06-08 20:29                   ` Peter Stephenson
2014-06-08 21:01                   ` Bart Schaefer
2014-06-08 21:50                     ` Peter Stephenson
2014-06-09  2:11                       ` Bart Schaefer
2014-06-12 19:35                         ` Peter Stephenson
2014-06-13  6:57                           ` Bart Schaefer
2014-06-13  9:55                             ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140613105507.7d11572e@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).