Date: Thu, 22 Apr 2021 22:53:25 +0200
> The idea generalizes:
>
> 1) ..while the result of an operation with particular characteristic
> $foo on an object X is within its lifetime..
> 2) ..operations with another particular characteristic $bar on X are ill-formed
this would be useful, too, but goes far beyond what I propose. And I am
not even sure how we can ensure something like this if the code in
question is in separate compilation unit, I think this would require
extensive changes to the type system.
> how to try and fit that general idea into C++. I would wager a guess
> that it would be more attractive if it can do more
> than just the borrowing you illustrate. On the other hand, if it tries
My proposal is more limited in that I only want to support borrowing as
discussed here:
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
But note that borrowing is a very powerful concept. When we combine that
with controlled pointers (e.g., smart pointers that can either prove
that the access is safe or introduce runtime checks), we can eliminate
all memory bugs. As Rust has demonstrated. And I think that is extremely
useful. The price, of course, is that this requires some changes to
coding style.
Best
Thomas
>
> 1) ..while the result of an operation with particular characteristic
> $foo on an object X is within its lifetime..
> 2) ..operations with another particular characteristic $bar on X are ill-formed
this would be useful, too, but goes far beyond what I propose. And I am
not even sure how we can ensure something like this if the code in
question is in separate compilation unit, I think this would require
extensive changes to the type system.
> how to try and fit that general idea into C++. I would wager a guess
> that it would be more attractive if it can do more
> than just the borrowing you illustrate. On the other hand, if it tries
My proposal is more limited in that I only want to support borrowing as
discussed here:
https://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html
But note that borrowing is a very powerful concept. When we combine that
with controlled pointers (e.g., smart pointers that can either prove
that the access is safe or introduce runtime checks), we can eliminate
all memory bugs. As Rust has demonstrated. And I think that is extremely
useful. The price, of course, is that this requires some changes to
coding style.
Best
Thomas
Received on 2021-04-22 15:53:28