
Sorry I think I was not being clear due to differing understandings or using of the definitions of terms (likely on my part). The second built point is what I was considering, "ownership" of an object is moved out of the scope/frame/however you think about it, into the one you are calling. The only point I would say is that it does not need imply it is destroyed or consumed the function itself may return "ownership" with a return value, just that it is an error to access it through that binding, whatever the underlying implementation is doing (shared references, actual shuffling of pointers on a stack etc). Rust uses this behavior extensively in its compiler to reason about lifetimes of objects. I will see if I can dig up some of the hacks I have seen on this to use as examples of behaviors over this holliday. I can't remember which package I saw it in, but I remember one did it so It could efficiently reuse things like large numerical arrays since it could be sure nothing else is going to try to use the original object and potentially get nonsense as result. On Thu, Nov 26, 2020 at 5:15 PM Guido van Rossum <guido@python.org> wrote:
On Thu, Nov 26, 2020 at 1:51 PM Bruce Leban <bruce@leban.us> wrote:
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.
I don't think Python is ready for const arguments (the first bullet). "Const propagation" can be a real problem.
The second seems to be what the OP is after, and I now can see the use case -- in fact in libraries for scientific computing and/or machine learning I think Iv'e seen are a bunch of hacks to imply transfer of ownership that might benefit from this. But I'm not yet sufficiently familiar with that field to be able to point you to examples. Hopefully there are readers here who can. (Nate?)
-- --Guido van Rossum (python.org/~guido) *Pronouns: he/him **(why is my pronoun here?)* <http://feministing.com/2015/02/03/how-using-they-as-a-singular-pronoun-can-c...> _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-leave@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/VPD2Q5... Code of Conduct: http://python.org/psf/codeofconduct/
-- Nate Lust, PhD. Astrophysics Dept. Princeton University