[Python-ideas] Syntactic sugar to declare partial functions

Abe Dillon abedillon at gmail.com
Fri Aug 10 18:20:25 EDT 2018


[Neil Girdhar]

> I prefer partial since many programmers studied computer science


Many did not. I studied electrical engineering and wouldn't have been able
to tell you what the word 'partial' meant four years ago even though I've
been programming in one form or another since the late nineties. Many
programmers are scientists, engineers, financial analysts, etc. I'm pretty
sure I know what a closure is or what currying is, but if you put me on the
spot, I'd probably turn to Wikipedia to make sure I don't screw up the
definition.

[Neil Girdhar]

> It makes the concepts easier to google.


That can be an important criteria, but it can also be a red-herring. If an
implementation is clear enough, few people would have to google it. If,
however, you use obscure enough words like "lambda", people will google it
every day and still find it confusing. The ternary expression is difficult
to google if you don't know the jargon "ternary", but there's less of a
need to google it because it's pretty obvious how it works based simply on
its implementation.

[Steven D'Aprano]

> It's a clear, *generic* meaning that doesn't have any association with
> partial application.
> We'd be trying to create that association from scratch.


Sure, that's a good point. I don't think that sounds like such a big
problem, but I also don't hate 'partial'. I just prefer 'given'.
At any rate, I don't find the google-ablilty argument super strong because
there are many constructs that are difficult to google, but still pretty
great (e.g. comprehensions).

[Steven D'Aprano]

> > Words like 'partial', 'curry', 'lambda', and 'closure' are fine
> > for text books, published papers, and technical discussion,
> And programmers.
>

Yes, technical discussion among programmers.

[Steven D'Aprano]

> Programming is a technical skill with its own jargon. Classes,
> inheritence, exceptions, trampolining, processes, threads, protocols,
> imports, decorator, builders... we are happy with all those, why should
> we fear partial and lambda?


I get that programming carries it's own jargon and I understand that it has
a beneficial function. It can facilitate concise communication of nuanced
concepts. It can also be a needlessly confusing way to convey otherwise
simple concepts. In the latter case, it can feel like the intent is to
create an air of superiority through esoteric language. I feel like "curry"
and "lambda" are needlessly un-descriptive and confusing. "partial" really
isn't that bad, I just prefer "given" because I think it's pretty clear.
I've never heard of "trampolining", but if I had to guess: it's probably
related to recursion that involves more than one function?

I suspect that most programmers couldn't describe the difference between a
type and a class.
I suspect that most programmers couldn't tell you the difference between an
exception or an error.
I know that lots of programmers refer to the "__init__" method as a
"constructor" instead of an "initializer".

Precision is less of a problem In a programming language. `func.given`
doesn't have dozens of possible meanings. It's meaning has to be completely
unambiguous to the machine.

[Steven D'Aprano]

> > but I think
> > they would (or do in the case of 'lambda') harm Python.
> That's an extreme overreaction.


Extreme? I thought it was a rather benign opinion. I'm not exactly frothing
at the mouth here. It's not like I'm declaring holy war on Python for using
the word 'lambda'. I just think it was a mistake (and thatdeath should come
to all non-believers).

[Steven D'Aprano]

> Do you mean to imply that there are people who looked at Python, loved
> the language, but decided to use something else because they didn't like
> the choice of the keyword "lambda"?


No. Not at all. Is that what you got out of my sentence? Am I really the
one being extreme?

[Steven D'Aprano]

> If not, in what way is Python harmed? Would it be faster if the keyword
> was "function", or use less memory, or more expressive?


I didn't realize I'd hit such a nerve. I think there are better ways that
anonymous functions could have been implemented.  I've already said in past
discussions, I think the expression should come before the signature
because the signature is often obvious from context so placing it before
the logic is kinda noisy. I don't know what the best syntax would have
been, but I refuse to believe that an esoteric word from an esoteric branch
of calculus with an arbitrary etymology was the absolute best choice
available. I think the harm that choice caused is relatively minor, but I
don't think it was a great choice. I'm truly sorry if I hurt your feelings.

[Steven D'Aprano]

> Remember that to millions of programmers in the world, "function" is
> just as much an obscure foreign piece of jargon they have to memorise as
> "lambda" is to English-speakers.


Maybe we should use Egyptian Hieroglyphs then. Even the playing field. It
doesn't matter anyway, right? It's all nonsense to someone...

Honestly, I don't think 'partial' is that bad. I just wanted to support
your own comment:

although possibly a less jargon name would be nicer:
>     add1 = add.given(1)


But you seem to have some grudge against me. I don't get all the outrage
over what I thought was a fairly benign post.
Did I do something to make you so angry at me? I'd like to resolve whatever
it is instead of having to deal with this every time I post.

On Fri, Aug 10, 2018 at 2:09 AM, Steven D'Aprano <steve at pearwood.info>
wrote:

> On Thu, Aug 09, 2018 at 01:32:00PM -0500, Abe Dillon wrote:
> > I'd like to push for the less jargon-y `func.given()` version if this
> gains
> > traction. Not only is it shorter, it's a much more common term with a
> clear
> > meaning.
>
> It's a clear, *generic* meaning that doesn't have any association with
> partial application.
>
> https://www.google.com/search?q=function+given
>
> We'd be trying to create that association from scratch.
>
>
> > Words like 'partial', 'curry', 'lambda', and 'closure' are fine
> > for text books, published papers, and technical discussion,
>
> And programmers.
>
> Programming is a technical skill with its own jargon. Classes,
> inheritence, exceptions, trampolining, processes, threads, protocols,
> imports, decorator, builders... we are happy with all those, why should
> we fear partial and lambda?
>
>
> > but I think
> > they would (or do in the case of 'lambda') harm Python.
>
> That's an extreme overreaction.
>
> Do you mean to imply that there are people who looked at Python, loved
> the language, but decided to use something else because they didn't like
> the choice of the keyword "lambda"?
>
> If not, in what way is Python harmed? Would it be faster if the keyword
> was "function", or use less memory, or more expressive?
>
> Remember that to millions of programmers in the world, "function" is
> just as much an obscure foreign piece of jargon they have to memorise as
> "lambda" is to English-speakers.
>
>
> --
> Steve
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180810/fe77e7a5/attachment-0001.html>


More information about the Python-ideas mailing list