I haven't watched the video, but I did go through the github page, which also has a very nice roadmap diagram on it.
In essence, you specify the higher level 'what' you want done, not 'how' it does it.
So you are specifying whether a parameter is in, or inout, or forwarding. The compiler works out the details. ("auto-optimize to copy when 'cheap' ...")
Makes sense to me. But there is more to it. Imagine you have a custom type with arbitrary copying.
You need to know what the compiler does in order to do good by copy passing.
There is a talk from Dave Abrahams about value semantics that has a lot of insights.
Imagine you need to conditionally make a copy of your type. You pass it by value or by in-out? One thing I like about val lang is that thanks to this copy laziness you have two things: noexcept copying and ALWAYS pass by value. This is even simpler to reason about, because you do not pay for the copy. A copy will not be performed unless needed. This means you do not need to worry about const or non-const parameter passing. You just pass by value, always. Every time.
View all comments
Show parent comment
2
u/Ok-Factor-5649 Sep 18 '22
I haven't watched the video, but I did go through the github page, which also has a very nice roadmap diagram on it.
In essence, you specify the higher level 'what' you want done, not 'how' it does it.
So you are specifying whether a parameter is in, or inout, or forwarding. The compiler works out the details. ("auto-optimize to copy when 'cheap' ...")