zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Cc: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Subject: Re: min() max() math functions (was: Re: Feature request (@M):# with context matches)
Date: Wed, 10 Feb 2016 09:23:24 +0000	[thread overview]
Message-ID: <20160210092324.GA6339@tarsus.local2> (raw)
In-Reply-To: <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[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


  reply	other threads:[~2016-02-10  9:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAKc7PVDCOPzbU25+vTAXMQjonS1sznDX_SBq4-8rUZPQewa5Tg@mail.gmail.com>
     [not found] ` <CAKc7PVAe0N2bp2XS5U4mOKnTgxQRsj4UGy7NQpHput9VsbnAJw@mail.gmail.com>
     [not found]   ` <160130085456.ZM9730__49922.0612728552$1454172936$gmane$org@torch.brasslantern.com>
     [not found]     ` <20160207002212.GC24068@tarsus.local2>
     [not found]       ` <160206170040.ZM1927__13399.3204137825$1454806909$gmane$org@torch.brasslantern.com>
     [not found]         ` <20160209032308.GA20947@tarsus.local2>
2016-02-09  5:22           ` Bart Schaefer
2016-02-10  9:23             ` Daniel Shahaf [this message]
2016-02-10 17:41               ` Bart Schaefer
2016-02-14 14:33                 ` Daniel Shahaf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160210092324.GA6339@tarsus.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=sgniazdowski@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).