From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 87fad5b3 for ; Sun, 26 Jan 2020 00:46:16 +0000 (UTC) Received: (qmail 22653 invoked by alias); 26 Jan 2020 00:46:08 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45342 Received: (qmail 15079 invoked by uid 1010); 26 Jan 2020 00:46:08 -0000 X-Qmail-Scanner-Diagnostics: from wout1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25699. spamassassin: 3.4.2. Clear:RC:0(64.147.123.24):SA:0(-2.6/5.0):. Processed in 7.233286 secs); 26 Jan 2020 00:46:08 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrvdekgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfgjfhfogggtgfesthhqtd dtredtjeenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghnihgv lhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudektddrheejrdduudelnecuve hluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugdrshesuggr nhhivghlrdhshhgrhhgrfhdrnhgrmhgv X-ME-Proxy: Date: Sun, 26 Jan 2020 00:45:18 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: Re: Unset =?UTF-8?B?4oCcemxlX2JyYWNrZXRlZF9wYXN0ZeKAnQ==?= .zshrc Message-ID: <20200126004519.6e44ae68@tarpaulin.shahaf.local2> In-Reply-To: <1579773213.5343.1.camel@samsung.com> References: <0723EF0A-BD62-4C2C-AAA1-735AD3D64768@icloud.com> <20200123031249.034c7e1a@tarpaulin.shahaf.local2> <1579773213.5343.1.camel@samsung.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable [ Sorry for the delay; I wanted to sleep on this before sending. ] Peter Stephenson wrote on Thu, 23 Jan 2020 09:53 +0000: > On Thu, 2020-01-23 at 03:12 +0000, Daniel Shahaf wrote: > > I haven't tried to implement this yet, but what I have in mind is > > (1)=C2=A0Make unsetparam_pm() add the PM_UNSET bit if the PM_AUTOLOAD b= it is > > present; (2)=C2=A0Make module loading, before creating a parameter, che= ck if > > there's a Param with PM_UNSET and PM_AUTOLOAD both set; if there is, > > rather than create the "real" parameter, delete the tombstone parameter. > > (But if there isn't a Param at all, the module _should_ create its spec= ial > > Param anyway, to allow modules to be unloaded and reloaded in the same > > shell session.) =20 >=20 > The obvious expected behaviour would be for it to have the same > behavious as unsetting the parameter after the module is loaded.=C2=A0=C2= =A0But a > quick tests suggests that doesn't work for readonly parameters, for one > --- all that would happen is that would produce an error when the module > is loaded, which doesn't really make much sense. In what case would an error happen upon loading of the module? The only error I see is this: % zsh -fc 'unset builtins; zmodload zsh/parameter' % % zsh -fc 'zmodload zsh/parameter; unset builtins'=20 zsh:1: read-only variable: builtins zsh: exit 1 zsh -fc 'zmodload zsh/parameter; unset builtins' %=20 And I think it makes sense, because trying to unset a non-autoloadable readonly parameter gives the same error. > So in that case, at least, the behaviour above is as logical as > anything. >=20 > [...] The autoload flag effective means the parameter behaviour defers to > the module. In other words, the rule is a parameter should only be unset by explicitly calling the =C2=ABunset=C2=BB builtin; loading and unloading the= module doesn't affect the parameter's existence. Thanks, this makes sense. How about the following spec? =E2=80=94 [[[ diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst index 1bd8c1900..854e21da0 100644 --- a/Test/V01zmodload.ztst +++ b/Test/V01zmodload.ztst @@ -348,6 +348,47 @@ ?(eval):6: unknown function: systell ?(eval):9: file descriptor out of range =20 + $ZTST_testdir/../Src/zsh -fc ' + if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi + unset options + zmodload zsh/parameter + echo $+options + ' +-f:can unset a non-readonly autoloadable parameter before loading the modu= le +>0 +# Currently prints '1'. + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + unset options + echo $+options + ' +0:can unset a non-readonly autoloadable parameter after loading the module +>0 + + $ZTST_testdir/../Src/zsh -fc ' + if zmodload -e zsh/parameter; then zmodload -u zsh/parameter; fi + unset builtins + ' +-f:can't unset a readonly autoloadable parameter before loading the module +*?zsh:?: read-only variable: builtins +# Currently, the 'unset' succeeds. + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + unset builtins + ' +1:can't unset a readonly autoloadable parameter after loading the module +?zsh:3: read-only variable: builtins + + $ZTST_testdir/../Src/zsh -fc ' + zmodload zsh/parameter + zmodload -u zsh/parameter + echo $options + ' +0:unloading a module doesn't implicitly unset autoloadable parameters +*>(on|off) * + %clean =20 eval "$deps" ]]] (Note that two of the five cases currently fail.) > Documenting the current behaviour is perfectly respectable. We could do this for 5.8,=20 but I'd like to take a shot at the general case too. (Though I already have a backlog of patches I want to finish, or in some cases start.) > Remember, you can use zmodload -F to manipulate which features > are provided by a module, although not at the point of declaring > autoloads --- some sort of autoloadable feature set might be another > way of doing this. How do you envision this working? Would there be, say, a zmodload flag to add/remove entries from the default set of autofeatures? Or would =C2=ABunset options=C2=BB implicitly twiddle the autofeatures metadata for = the (not-yet-loaded) zsh/parameter module? Thanks, Daniel