Subject: Re: [PATCH] 'functions -T' tracing: recurse into anonymous functions.
From: Daniel Shahaf <[email-masked]>
To: [email-masked]
Date: Sun, 12 Jun 2016 14:29:32 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Bart Schaefer wrote on Fri, Jun 10, 2016 at 21:06:32 -0700:
> On Jun 10,  5:37pm, Daniel Shahaf wrote:
> }
> }  for this function; the flag tt(-T) does the same, but turns off tracing
> }  on any function called from the present one, unless that function also
> } -has the tt(-t) or tt(-T) flag.  The tt(-u) and tt(-U) flags cause the
> } +has the tt(-t) or tt(-T) flag or is anonymous.  The tt(-u) and tt(-U) flags cause the
> 
> That phrasing is a little hard to follow.  Perhaps something more like:
> 
> ... turns off tracing
> for any named (not anonymous) function called from the present one, unless
> that function also ...
> 
> Note I'm also suggesting changing "turns off tracing on" into "turns off
> tracing for" to reduce the chances of off/on confusion.

Good call.  Will fix before pushing.

> (Further, don't be afraid to reformat paragraphs if lines get long.)
> 

I generally avoid rewrapping paragraphs completely since default diff
tools tend to be line-based and therefore don't render such diffs
readably.

I'll break the long line into two.  (That will leave a short line, similar
to 38155.  I can rewrap the paragraph if a short line is a problem.)

> I've been considering something similar for the zsh/param/private module
> to make caller private variables visible inside anonymous functions, but
> haven't worked out all the necessary stack management.

I've also been considering something similar: I'd like PRINT_EXIT_VALUE
to recurse into anonymous functions.  IIRC the problem I ran into was
that the return value of the last command in the anon func, and of the
anon func itself, were both printed (despite being equal).