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

Re: [PATCH] Fix ERR_EXIT behavior in function calls and "always" statements



On 22/11/2022 02:52 Philippe Altherr <philippe.altherr@xxxxxxxxx> wrote:
> Currently anonymous functions behave like function calls. My patches
> don't change that but they change/fix cases F and I to behave as mandated
> by POSIX. If anonymous functions are changed to behave like compound
> commands then anonymous functions behave as if the code was inlined.
> This changes the behavior of case E, which currently exits.

On the whole I think keeping anonymous functions behaving like other functions
is probably sensible, though we could draw better attention to this unusual
degree of consistency somewhere in the documentation.

I don't think there's a killer argument for this but if you're using an
anonymous function it's because you need some form of function behaviour and
my own inclination would be to continue to provide essentially the whole of it,
hopefully also limiting special cases in the source code.

(One possible comparison is Ruby, where you consistently either get "yield
semantics" or "function semantics", though comparing zsh with Ruby feels
wrong at pretty much every other level so this is a very shallow similarity
indeed.)

pws




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