On Thu, Nov 26, 2020 at 5:43 AM <3mi...@gmail.com> wrote:

> Add something like Move type hint to typing module. It will tell the
> analyzer that the input parameter of the function is moved and can not be
> used after. For example:
> ```
>

You say "moved and cannot be used" which is either incomplete, ambiguous,
contradictory, or some combination of those. Moved where and who can't use
it? What you really are talking about is "taking ownership." But then
you're omitting the key detail that it also gives ownership back via the
return value. Otherwise what you would want to indicate is that the
function destroys the value.

Since the semantics of Python are that objects are always passed by
reference, it's implied that control of the object is passed to the called
function. I think

What might be useful are declarations that:

   - The object is not modified (i.e., read only). If a function that
   declares a parameter as read-only passes that parameter to one that does
   not use that declaration, that can be identified as an error.
   - The object is destroyed or consumed by the function. Any use of the
   object after calling the function could be identified as an error.

--- Bruce
_______________________________________________
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/X2EKBHLEOY7SSSHNG3TAFJZ2UCKZYRJ6/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to