Subject: Re: When local state_descr is needed?
From: Oliver Kiddle <[email-masked]>
To: zsh workers <[email-masked]>
Date: Thu, 09 Jun 2016 16:43:44 +0200
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Marko Myllynen wrote:
>
> It's a bit unclear to me when local state_descr should be declared.
> Reading the man page makes me think that it certainly doesn't hurt to
> do it especially when using the ->string convention but is it in fact
> needed then to avoid any potential or concrete side-effect?

_main_complete declares it local so it mostly isn't needed.

state_descr was added much later so there were many existing functions
that didn't declare it local. Even before, we've often been lax about
declaring opt_args.

I can think of contrived cases where it would be needed. You'd need to
be using it in a state loop where _arguments/_values is also being
called as part of handling a state.

I tend to only declare it in functions that reference it.
I don't think it's really worth patching vast numbers of functions for
it but I wouldn't care either if someone wants to.

Oliver