On Sat, Oct 30, 2021, 11:03 PM Chris Angelico

> That's if you were to create a deferred *type*. An object which can be
> evaluated later. My proposal is NOT doing that, because there is no object
> that represents the unevaluated expression. You can't pull that expression
> out and evaluate it somewhere else. It wouldn't be meaningful.
>

Put this way, I admit it is intelligible. Maybe it even reduces the order
of magnitude of my opposition to it.

What you are trying to create remains a "unit of computation" even though
it is not itself a Python object. As Brendan points out, this is a
fundamental change to Python's object model.

It amounts to saying "I want to perform some computation within the body of
a function, but I don't want to WRITE it in the body of a function." That
feels like an anti-goal to me.

But it's true that the code fragment 'if a is None: a = calculated()' is
also not itself a first class object. So a synonym for that I can
understand, albeit dislike.

I suppose I don't *hate* something like this, which can be done with no
syntax change:

@rewrite
def foo(a, size=Late("len(a)")):
    print("The list is length", size)

In the functions I actually use and write, the problem all of this is
trying to solve is either trivial or irrelevant.

In libraries like Pandas, for example, there are often tens of arguments
with defaults of None... But it is rarely a single default to resolve.
Rather, there is complex logic about the interaction of which arguments are
provided or absent, leading to numerous code paths to configure the actual
behavior of a call.

For these, the logic of missing arguments must live in the body, where it
naturally belongs.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/EWWXV4LONSWDHAGGCNLWDH2KPUOWERJI/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to