Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: `try' syntax



Oliver Kiddle wrote:
> 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.

It doesn't handle exits, exits are immediate.  That's why it doesn't
mention it.

> What happens if break, continue, return or exit are used within the
> always block?

They are ignored (except exit).  Statuses generally use the value from
the try 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.

But it exactly indicates whether or not there's an error.  $? indicates
the status.

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

$? is like the other variables, it's restored after the always block
to what it was in the try block.  (Internally, the exectry returns the
try block status or'd with the error flag --- I think that's redundant
but it seemed safer --- which gets stored in lastval.)

-- 
Peter Stephenson <pws@xxxxxxx>                  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
**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author