zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: break/continue vs. try-always
Date: Fri, 06 Jun 2014 23:22:50 -0700	[thread overview]
Message-ID: <140606232250.ZM23057@torch.brasslantern.com> (raw)
In-Reply-To: <20140606224523.09d5f22c@pws-pc.ntlworld.com>

On Jun 6, 10:45pm, Peter Stephenson wrote:
}
} On Fri, 6 Jun 2014 14:08:53 -0700
} Bart Schaefer <schaefer@brasslantern.com> wrote:
} > On Jun 6, 2014 2:04 PM, "Peter Stephenson" <p.w.stephenson@ntlworld.com>
} > wrote:
} > 
} > I was thinking perhaps "break 0" which is otherwise/currently an error.
} 
} 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".

I don't understand what "return -r" would do.  Unlike "break 1000" for
example, and except for the weird case of 'trap return EXIT', "return"
can't affect anything beyond the local scope.  E.g., where one might
do

    outer() {
      while (($#)); do { inner $1; shift } always { break 0 }; done
    }

to prevent inner from stopping the loop in outer, I don't see any case
in which the always block would need to cancel a return.

} 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.

There may already be a conflict there, e.g.

  while print one; do
    while print two; do
      while print three; do
	  { break 2 } always { continue 3 }
      done
    done
  done

In fact if there are both a "break" and a "continue" in the try-always,
the effect is as if "continue" were called with the larger loop count,
no matter which of them appears in the try vs. the always blocks.

So we should probably define those semantics before we figure out what
a value of 0 (or whatever) means.


  reply	other threads:[~2014-06-07  6:23 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 [this message]
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

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=140606232250.ZM23057@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).