zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: `try' syntax
Date: Tue, 15 Jun 2004 14:33:01 +0100	[thread overview]
Message-ID: <200406151333.i5FDX275000620@news01.csr.com> (raw)
In-Reply-To: "Bart Schaefer"'s message of "Mon, 14 Jun 2004 11:14:47 PDT." <Pine.LNX.4.44.0406141015190.32342-100000@toltec.zanshin.com>

Bart Schaefer wrote:
> * A "shortloops" form "try { ... }" might be nice, or maybe should be the
> only form.

It's rather nonstandard.

> * 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"

That's mixing up the syntax in exactly the way I wanted to avoid.
I wanted the `try' bit to be separate so that it was clear what
was going on.

> * 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.)

Yes, it's interesting, but the problem with functions is difficult.
An extra flag to autoload could specify extended syntax.

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

Currently you do need to disable both.

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

You'd need to use errreturn, since exit is immediate.  Otherwise
it works.

Oliver wrote:
> Or, thinking along those lines, you could use something like
> { ... } always { ... }
> That currently finds a syntax error at always.

This is definitely an interesting suggestion...

Syntactically, it's still a bit tricky.  Either `always' is a keyword,
or it isn't.  If it is it generates a syntax error when used elsewhere.
If it isn't, we have to convert the string into a token in this one
case.  Maybe that's not so hard, though.

The other part is that we don't know till we get to the `always'
whether there is an always present.  Possibly it could just be
tacked onto ordinary current-shell structures.

As things stand I'm not sure I'm going to have any free time before
2008, but if I do is this worth trying?  (In other words, is it
reasonably agreeable to everyone interested?)

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


  parent reply	other threads:[~2004-06-15 13:34 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
2004-06-15 10:31         ` Oliver Kiddle
2004-06-15 10:51         ` DervishD
2004-06-15 13:33         ` Peter Stephenson [this message]
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=200406151333.i5FDX275000620@news01.csr.com \
    --to=pws@csr.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).