zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: `try' syntax
Date: Mon, 14 Jun 2004 11:14:47 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.44.0406141015190.32342-100000@toltec.zanshin.com> (raw)
In-Reply-To: <29441.1087232105@trentino.logica.co.uk>

On Mon, 14 Jun 2004, Peter Stephenson wrote:

> Here's an experimental and possibly controversial (though, I think,
> working) new syntax for running code protected from error and other
> conditions in an internal block.
[...]
> 
> The trickiest bit is the naming.  I wanted something reasonably
> memorable, but without polluting the name space, hence the names
> with the colons in front.

I have several suggestions, in no particular order (and I'm deleting the
ones that overlap with Oliver as I find them).

* I'm not thrilled with "try" and "always" but I haven't yet come up with
anything better.

* A "shortloops" form "try { ... }" might be nice, or maybe should be the
only form.

* How about making this work with any loop body by replacing "do" with
"try"?  Then get rid of "try" as a standalone reserved word and instead
use "repeat 1; try ... always ... done"

* Rather than putting colons or some other unlikely character in front of
the name, use plain words and start with them "disable"d, so that in order
to use this syntax one must first "enable -r try always tried".  (This
technique could apply to other extension syntax as well.)

* Tangential thought: Is it really necessary to disable e.g. both "case"
and "esac" or is it sufficient to disable (and enable) "case"?

On Mon, 14 Jun 2004, Peter Stephenson wrote:

> Oliver Kiddle wrote:
> > It could be useful to
> > have something like the errexit and errreturn options apply within the
> > try block.
> 
> They do, but to the enclosing function (the always block would be
> executed).

So does that mean that

   :try
     setopt errexit
     false
     print not reached 1
   :always
     print reached
   :tried
   print not reached 2

prints only "reached"?  Then that's a non-obvious way to accomplish what
Oliver wanted:

> > It'd be really useful to have a way to skip over the rest of the try
> > block, going straight to the always code.

On Mon, 14 Jun 2004, Oliver Kiddle wrote:

> TRY_ERROR sounds fine though I might go for TRY_STATUS
> 
> > (I wonder if it could be setable inside the try block to force errflag
> > to 1, forcing the rest of the block to be skipped? [...])
> 
> That's an interesting idea. Would be useful. Having a variable
> assignment affect control flow would be more than a bit weird, though.

I agree that it would be weird.  Another new keyword would be better
(see my suggestion about starting disabled).


  parent reply	other threads:[~2004-06-14 18:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-14 11:23 Peter Stephenson
2004-06-14 12:58 ` Oliver Kiddle
2004-06-14 13:52   ` Peter Stephenson
2004-06-14 16:55     ` Oliver Kiddle
2004-06-14 17:27       ` Peter Stephenson
2004-06-14 18:14       ` Bart Schaefer [this message]
2004-06-15 10:31         ` Oliver Kiddle
2004-06-15 10:51         ` DervishD
2004-06-15 13:33         ` Peter Stephenson
2004-06-15 20:21           ` Bart Schaefer
2004-06-16 14:33             ` Oliver Kiddle
2004-06-16 17:21               ` Bart Schaefer
2004-06-18 11:05                 ` PATCH: second go at `always' blocks 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=Pine.LNX.4.44.0406141015190.32342-100000@toltec.zanshin.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-workers@sunsite.dk \
    /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).