* When local state_descr is needed?
@ 2016-06-09 9:57 Marko Myllynen
2016-06-09 14:43 ` Oliver Kiddle
0 siblings, 1 reply; 3+ messages in thread
From: Marko Myllynen @ 2016-06-09 9:57 UTC (permalink / raw)
To: zsh workers
Hi,
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?
For example, does the patch below matter in practice at all or not?
In the file later on there is:
"(-f --from-code $exargs)"{-f+,--from-code=}'[specify code set of input file]:code set:->from_codeset'
"(-t --to-code $exargs)"{-t+,--to-code=}'[specify code set for output]:code set:->to_codeset'
---
Completion/Unix/Command/_iconv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv
index d040be7..fd74e6b 100644
--- a/Completion/Unix/Command/_iconv
+++ b/Completion/Unix/Command/_iconv
@@ -1,6 +1,6 @@
#compdef iconv
-local expl curcontext="$curcontext" state line variant ret=1
+local expl curcontext="$curcontext" state state_descr line variant ret=1
if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC|Gentoo)' unix --version; then
local -a args
Thanks,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: When local state_descr is needed?
2016-06-09 9:57 When local state_descr is needed? Marko Myllynen
@ 2016-06-09 14:43 ` Oliver Kiddle
2016-06-09 18:10 ` Marko Myllynen
0 siblings, 1 reply; 3+ messages in thread
From: Oliver Kiddle @ 2016-06-09 14:43 UTC (permalink / raw)
To: zsh workers
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: When local state_descr is needed?
2016-06-09 14:43 ` Oliver Kiddle
@ 2016-06-09 18:10 ` Marko Myllynen
0 siblings, 0 replies; 3+ messages in thread
From: Marko Myllynen @ 2016-06-09 18:10 UTC (permalink / raw)
To: zsh-workers
Hi,
On 2016-06-09 17:43, Oliver Kiddle wrote:
> 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 tend to only declare it in functions that reference it.
> I don't think it's really worth patching vast numbers of functions [...]
Thanks, all clear now.
Cheers,
--
Marko Myllynen
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-06-09 18:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 9:57 When local state_descr is needed? Marko Myllynen
2016-06-09 14:43 ` Oliver Kiddle
2016-06-09 18:10 ` Marko Myllynen
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).