zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: return up two levels?
Date: Tue, 11 Mar 2014 07:54:38 -0700	[thread overview]
Message-ID: <531F23AE.5020404@eastlink.ca> (raw)
In-Reply-To: <CABx2=D-M5H1bFq=34r14RotX6hmghEh-6yW9RPyehL_NCQWQoA@mail.gmail.com>

On 03/10/2014 08:33 PM, Kurtis Rader wrote:
> Please don't use that technique unless it's in the context of something
> atypical like a debugger. It's a really bad software pattern. It's spooky
> action at a distance. It's a form of monkey-patching. it practically
> guarantees hard to debug errors. Plus a large number of other problems.
> Don't do it. Be explicit about return values. If you want a caller of
> function2 to exit immediately have function2 return non-zero and test for
> that. For example,
>
> function2() { print I failed to do my job; return 1 }
> function1() { if ! function2; then; print unexpected failure; return 0; fi;
> print life is good }
>
Hmmm, sobering advice. I'm always looking to expand the techniques 
available to me,
and Peter's 'trap' idea does/would streamline my code for this one 
particular problem,
which is just a very short helper function called in almost all of my 
other functions  in
a trivial and routine sort of way where there are unlikely to be any 
strange issues. Still, this
trap thing violates the rule of least surprise and breaks the basic 
rules of code flow, so
I do take your point.  I guess if this sort of thing can be considered 
'standard zsh practice'
then I'm inclined to keep it, but if not, then out it goes.  But all the 
'sh's' have so many
abominable and dirty practices anyway that this trap would hardly stand 
out ;-)


      reply	other threads:[~2014-03-11 14:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-10 11:51 zdotdir Yuri D'Elia
2014-03-10 12:01 ` zdotdir Aaron Kaufman
2014-03-10 13:03   ` zdotdir Yuri D'Elia
2014-03-10 15:32 ` zdotdir Bart Schaefer
2014-03-10 17:28   ` zdotdir Yuri D'Elia
2014-03-10 18:25     ` return up two levels? Ray Andrews
2014-03-10 19:42       ` Peter Stephenson
2014-03-11  3:00         ` Ray Andrews
2014-03-11  3:33           ` Kurtis Rader
2014-03-11 14:54             ` Ray Andrews [this message]

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=531F23AE.5020404@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /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).