From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27513 invoked from network); 14 Jun 2004 16:56:38 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.86) by ns1.primenet.com.au with SMTP; 14 Jun 2004 16:56:38 -0000 Received: (qmail 10702 invoked from network); 14 Jun 2004 16:56:30 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 14 Jun 2004 16:56:30 -0000 Received: (qmail 11171 invoked by alias); 14 Jun 2004 16:56:23 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20046 Received: (qmail 11161 invoked from network); 14 Jun 2004 16:56:22 -0000 Received: from thor.dotsrc.org (HELO a.mx.sunsite.dk) (qmailr@130.225.247.86) by sunsite.dk with SMTP; 14 Jun 2004 16:56:19 -0000 Received: (qmail 10427 invoked from network); 14 Jun 2004 16:56:19 -0000 Received: from mail36.messagelabs.com (193.109.254.211) by a.mx.sunsite.dk with SMTP; 14 Jun 2004 16:56:18 -0000 X-VirusChecked: Checked X-Env-Sender: okiddle@yahoo.co.uk X-Msg-Ref: server-18.tower-36.messagelabs.com!1087232149!6898481 X-StarScan-Version: 5.2.10; banners=-,-,- X-Originating-IP: [158.234.9.163] Received: (qmail 16944 invoked from network); 14 Jun 2004 16:55:50 -0000 Received: from iris.logica.co.uk (158.234.9.163) by server-18.tower-36.messagelabs.com with SMTP; 14 Jun 2004 16:55:50 -0000 Received: from trentino.logica.co.uk ([158.234.142.61]) by iris.logica.co.uk (8.12.3/8.12.3/Debian -4) with ESMTP id i5EGtnUI005713 for ; Mon, 14 Jun 2004 17:55:49 +0100 Received: from trentino.logica.co.uk (localhost [127.0.0.1]) by trentino.logica.co.uk (Postfix) with ESMTP id 556807858660 for ; Mon, 14 Jun 2004 18:55:05 +0200 (CEST) X-VirusChecked: Checked X-StarScan-Version: 5.0.7; banners=.,-,- In-reply-to: <200406141352.i5EDqIW2015449@news01.csr.com> From: Oliver Kiddle References: <200406141352.i5EDqIW2015449@news01.csr.com> To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: PATCH: `try' syntax Date: Mon, 14 Jun 2004 18:55:05 +0200 Message-ID: <29441.1087232105@trentino.logica.co.uk> 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 Peter wrote: > Oliver Kiddle wrote: > > What exactly do break, continue and return do here? Are they unchanged, > > expecting an enclosing loop or function. > > Yes. The description in the manual is supposed to say that. The manual description should probably also mention exit along with break, continue and return. What happens if break, continue, return or exit are used within the always block? > > Or how about using special variable which > > indicates what the "error condition" is and have that be unset. > > Yes, that's possible, and it allows you to test for an error, too, which > the current syntax doesn't. Again, I couldn't think of a good name > which didn't potentially clash with a user variable. Perhaps TRY_ERROR > or even TRY_BLOCK_ERROR would be good enough. (It's not a status; > $? correctly indicates the status after the try block, but not whether > an error occurred.) TRY_ERROR sounds fine though I might go for TRY_STATUS if it can indicate a lack of error. Testing for an error could certainly be useful. Does $? get unchanged by the always block like with a trap or is that only if return or exit is used with an explicit 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 would give a > nice interaction with traps. This is getting dangerously close to > `throw'.) That's an interesting idea. Would be useful. Having a variable assignment affect control flow would be more than a bit weird, though. And without making TRY_ERROR an array, you couldn't skip out of nested try blocks. > > The colons make them look like labels. > > Not in any UNIX shell I've ever seen. DOS batch files have labels in that form and given their lack of any decent control flow statements, you need to use gotos a lot in them. It also isn't so dissimilar to other languages' (including the C shell) use of a trailing colon for labels or named blocks. So when I look at them, I think label. Oliver