On Borrow Checking
Dukc
ajieskola at gmail.com
Thu May 8 08:54:16 UTC 2025
On Wednesday, 7 May 2025 at 14:47:49 UTC, jmh530 wrote:
> 4) Add @trustediflive, similar to above such that it is
> @trusted if called by a @live function and @system otherwise.
> Let's the user make the decision, more flexible. I think
> @trustediflive is kind of in line with what you were suggesting.
To be honest I didn't think the solution in detail. My intention
was just to point out roughly what it would have to be like if
`@live`, is to be useful for `@safe`ty but I certainly didn't
intend to say it's necessarily the best way to go about it. A
totally different borrow checker is also a possibility.
There are many details to consider, like how do we check whether
the parameters passed to / value returned from the `@safe @live`
function using `@trustediflive` need to be borrow checked too?
And how do we declare the type of such a function? It's going to
be complicated.
I'm not sure whether a borrow checker is even worth it for D.
Probably, no matter how we do it, it's still going to be
complicated, and it's useful for only a pretty niche use case.
For the vast majority of your memory safety problems you can and
should just rely on the GC after all. Walter is writing something
along these lines in his OP.
But if it's worth it, either `@live` needs way more language
machinery to support it's purpose or we need an entirely new
solution.
More information about the Digitalmars-d
mailing list