On 11/26/20 6:44 AM, [email protected] 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: ``` def f(d: Move[dict]) -> dict: d['a'] = 2 return dd = {1: 2} f(d) print(d[1]) # mistake, using of moved value
Maybe I'm behind the times on the latest thinking in programming languages. I'm not familiar with "move semantics". Can someone explain what is wrong with the code above? What is the mistake? `print(d[1])` will work perfectly fine. The function changes the 'a' key, and then we access the 1 key. Should the example have used the same key in both places?
Thanks, --Ned. _______________________________________________ Python-ideas mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/[email protected]/message/YFXWLKABNQCFUOEM7PJW4FUWZVCZW3A5/ Code of Conduct: http://python.org/psf/codeofconduct/
