the need for sink #775
-
Just a quick question to check my understanding. A sink parameter is pass-by-move (ownership transfer). It seems to me this could be inferred (either statically or dynamically) for a let parameter, but that would result in potential implicit copies. Val (like Rust) wants to make every copy explicit. Is all that correct? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Indeed, all copies must be explicit in Val, including for "simple" data types like You can't infer transfer of ownership statically without an interpocedural analysis and doing it dynamically would incur prohibitive runtime costs. |
Beta Was this translation helpful? Give feedback.
-
I should clarify though that while a sink parameter is indeed pass-by-ownership transfer, there is no move operation involved. |
Beta Was this translation helpful? Give feedback.
Indeed, all copies must be explicit in Val, including for "simple" data types like
Int
.You can't infer transfer of ownership statically without an interpocedural analysis and doing it dynamically would incur prohibitive runtime costs.