From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1486 invoked by alias); 10 Feb 2016 09:23:30 -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: X-Seq: 37935 Received: (qmail 9865 invoked from network); 10 Feb 2016 09:23:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 Date: Wed, 10 Feb 2016 09:23:24 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Cc: Sebastian Gniazdowski Subject: Re: min() max() math functions (was: Re: Feature request (@M):# with context matches) Message-ID: <20160210092324.GA6339@tarsus.local2> References: <160130085456.ZM9730__49922.0612728552$1454172936$gmane$org@torch.brasslantern.com> <20160207002212.GC24068@tarsus.local2> <160206170040.ZM1927__13399.3204137825$1454806909$gmane$org@torch.brasslantern.com> <20160209032308.GA20947@tarsus.local2> <160208212222.ZM27970@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <160208212222.ZM27970@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) Bart Schaefer wrote on Mon, Feb 08, 2016 at 21:22:22 -0800: > On Feb 9, 3:23am, Daniel Shahaf wrote: > } How do I shield zmathfunc against callers that unsetopt functionargzero? > > Sticky emulation would do it for you. E.g. > > emulate zsh -c 'autoload -U zmathfunc' > Good to know. If I'm not mistaken, using this form would also fix the cshjunkiequotes problems Sebastian has been running into. Shouldn't this form be used more often? As in, wouldn't using this form be correct for the majority of autoloadable functions? > Or examine $funcstack[1] instead of $0 (with localoptions noksharrays), > although that introduces a dependence on zsh/parameter. > > } I guess I'll have to drop the the multifuncdef usage altogether? > > See for example zmv, zcp, zln. > I think the path of least resistance is to drop the multifuncdef usage, and not require the user to create symlinks or to have zsh/parameter [although that module is probably ubiquitous?] or to do the autoload specially. > Although it seems an oversight that you can't combine -u and -M for the > functions command. > Would this be easy to add? (Just another flag in the stub function structure, maybe?) I can check later but don't have time to right now. > } +Autoloading tt(zmathfunc) defines the three mathematical functions > > You do have to both autoload it and run it, like e.g. "colors". Indeed. How about: The function tt(zmathfunc) defines the three mathematical functions... > Given that, why not have zmathfunc perform "zmodload zsh/mathfunc" > too? > I don't see a good reason to force users of the autoload to use the module. It's a non-obvious side effect (consider somebody who does 'autoload zmathfunc && zmathfunc && zmodload -F ... zsh/mathfunc') that's not easy for the caller to disable. (But see below) > } +++ b/Doc/Zsh/mod_mathfunc.yo > } +The functions tt(min), tt(max), and tt(sum) are defined not in this module > } +but in the tt(zmathfunc) autoloadable function > > Ehh, I'm not sure it's the job of any module's doc to explain what it > does NOT define, much less to cross-reference zshcontrib. The functionality of zmathfunc is related to that of zsh/mathfunc. The reason they aren't the same thing is due to implementation considerations (we separated functions that can be implemented satisfactorily in shell code from those that must be implemented in C), not due to interface considerations. In fact, that's an argument in favour of making zsh/mathfunc autoload zmathfunc (sic, in this order). Why is it a problem for zshmodules to reference zshcontrib? Should zmathfunc's documentation be located elsewhere? Cheers, Daniel