On Thu, Aug 11, 2011 at 12:23:00AM -0700, pjodrr wrote:
> they call it "collapsing functions":
> http://wiki.bash-hackers.org/howto/collapsing_functions

"The first time you run chatter(), the function redefines itself based on the
value of verbose. Thereafter chatter doesn't check $verbose anymore, it simply
is. Further calls to the function reflect its collapsed nature. If verbose is
unset, chatter will echo nothing, with no extra effort from the developer."

The problem with this is that you can't switch to the other function
later.

unset verbose
chatter "$i"
...
verbose=1
chatter "$j"

Here, the first call to chatter blows away the test of $verbose, so
the next time we call it, the fact that we've set verbose=1 is ignored.
We're stuck in non-verbose mode forever.

Reply via email to