From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29792 invoked from network); 15 Jun 2004 13:34:08 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 15 Jun 2004 13:34:08 -0000 Received: (qmail 10527 invoked from network); 15 Jun 2004 13:33:58 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Jun 2004 13:33:58 -0000 Received: (qmail 22601 invoked by alias); 15 Jun 2004 13:33:50 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20053 Received: (qmail 22592 invoked from network); 15 Jun 2004 13:33:49 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 15 Jun 2004 13:33:46 -0000 Received: (qmail 10116 invoked from network); 15 Jun 2004 13:33:36 -0000 Received: from lhuumrelay3.lnd.ops.eu.uu.net (62.189.58.19) by a.mx.sunsite.dk with SMTP; 15 Jun 2004 13:33:34 -0000 Received: from MAILSWEEPER01.csr.com (mailhost1.csr.com [62.189.183.235]) by lhuumrelay3.lnd.ops.eu.uu.net (8.11.0/8.11.0) with ESMTP id i5FDX8v19530 for ; Tue, 15 Jun 2004 13:33:08 GMT Received: from EXCHANGE02.csr.com (unverified [192.168.137.45]) by MAILSWEEPER01.csr.com (Content Technologies SMTPRS 4.3.12) with ESMTP id for ; Tue, 15 Jun 2004 14:32:30 +0100 Received: from news01.csr.com ([192.168.143.38]) by EXCHANGE02.csr.com with Microsoft SMTPSVC(5.0.2195.6713); Tue, 15 Jun 2004 14:36:16 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.12.11/8.12.11) with ESMTP id i5FDX6vK000625 for ; Tue, 15 Jun 2004 14:33:06 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.12.11/8.12.11/Submit) with ESMTP id i5FDX275000620 for ; Tue, 15 Jun 2004 14:33:06 +0100 Message-Id: <200406151333.i5FDX275000620@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: Zsh hackers list Subject: Re: PATCH: `try' syntax In-reply-to: "Bart Schaefer"'s message of "Mon, 14 Jun 2004 11:14:47 PDT." Date: Tue, 15 Jun 2004 14:33:01 +0100 From: Peter Stephenson X-OriginalArrivalTime: 15 Jun 2004 13:36:16.0046 (UTC) FILETIME=[BB840CE0:01C452DD] X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=0.0 required=6.0 tests=BAYES_50 autolearn=no version=2.63 X-Spam-Hits: 0.0 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 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 **********************************************************************