Zsh Mailing List Archive
Messages sorted by:
Re: min() max() math functions (was: Re: Feature request (@M):# with context matches)
- X-seq: zsh-workers 37935
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: min() max() math functions (was: Re: Feature request (@M):# with context matches)
- Date: Wed, 10 Feb 2016 09:23:24 +0000
- Cc: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- In-reply-to: <160208212222.ZM27970@torch.brasslantern.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVDCOPzbU25+vTAXMQjonS1sznDX_SBq4-8rUZPQewa5Tg@mail.gmail.com> <CAKc7PVAe0N2bp2XS5U4mOKnTgxQRsj4UGy7NQpHput9VsbnAJw@mail.gmail.com> <160130085456.ZM9730__49922.firstname.lastname@example.org> <20160207002212.GC24068@tarsus.local2> <160206170040.ZM1927__13399.email@example.com> <20160209032308.GA20947@tarsus.local2> <160208212222.ZM27970@torch.brasslantern.com>
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 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
> 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"
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?
Messages sorted by: