<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>On May 6, 2015, at 12:50, Yann Kaiser <<a href="mailto:kaiser.yann@gmail.com">kaiser.yann@gmail.com</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div class="gmail_quote">On Wed, 6 May 2015 at 08:49 Guido van Rossum <<a href="mailto:guido@python.org" target="_blank">guido@python.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I realize this is still python-ideas, but does this really leave functions with multiple arguments completely out of the picture (except as the first stage in the pipeline)?</div></blockquote><div><br></div></div><div dir="ltr"><div class="gmail_quote"><div>To provide some alternative ideas, what I did in sigtools.wrappers.Combination[1] was to replace the first argument with the return value of the previous call while always using the same remaining (positional and keyword) arguments</div></div></div></div></div></blockquote><div><br></div><div>This is exactly my point about there not being one obvious right answer for dealing with multiple arguments. Among the choices are:</div><div><br></div><div> * Don't allow them.</div><div> * Auto-*-unpack return values into multiple arguments.</div><div> * Compose on the first argument, pass others along the chain.</div><div> * Auto-curry and auto-partial everywhere.</div><div> * Auto-curry and auto-partial and _also_ auto-*-unpack (which I'd never considered, but it sounds like that's what this thread proposes).</div><div><br></div><div>They've all got uses. But if you're going to write _the_ compose function, it has to pick one.</div><div><br></div><div>Also, keep in mind that "auto-curry and auto-partial everything" can't really mean "everything"--unlike Haskell, Python can't partial operator expressions, and we've still got *args and keyword-only params and **kw, and we've got C functions that aren't argclinic'd yet, and so on. (If that all seems like obscure edge cases, consider that most proxy implementations, forwarding functions, etc. work by just taking and passing along *args, **kw, not by inspecting and binding the signature of the wrappee.)</div><div><br></div><blockquote type="cite"><div><div dir="ltr"><div dir="ltr"><div class="gmail_quote"><div>. In code:</div><br>    def __call__(self, arg, *args, **kwargs):</div><div class="gmail_quote">        for function in self.functions:</div><div class="gmail_quote">            arg = function(arg, *args, **kwargs)</div><div class="gmail_quote">        return arg</div><div class="gmail_quote"><br></div><div class="gmail_quote">With this you can even use functions that use different parameters, at the cost of less strictness:</div><div class="gmail_quote"><br></div><div class="gmail_quote">    def func1(arg, *, kw1, **kwargs):</div><div class="gmail_quote">        ...</div><div class="gmail_quote"><br></div><div class="gmail_quote">    def func2(arg, *, kw2, **kwargs):</div><div class="gmail_quote">        ...</div><div class="gmail_quote"><br></div><div class="gmail_quote">That class is more of a demo for sigtools.signatures.merge[2] rather than something spawned out of a need however.</div><div class="gmail_quote"><br></div><div class="gmail_quote">[1] <a href="http://sigtools.readthedocs.org/en/latest/#sigtools.wrappers.Combination">http://sigtools.readthedocs.org/en/latest/#sigtools.wrappers.Combination</a></div><div class="gmail_quote">[2] <a href="http://sigtools.readthedocs.org/en/latest/#sigtools.signatures.merge">http://sigtools.readthedocs.org/en/latest/#sigtools.signatures.merge</a></div></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Python-ideas mailing list</span><br><span><a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a></span><br><span><a href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a></span><br><span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a></span></div></blockquote></body></html>