logoalt Hacker News

dnauticsyesterday at 7:21 PM1 replyview on HN

You can very likely borrow check in languages that don't have it in the type system. Exactly the way you suggest, as an optional add-in. It's still WIP but in my side project I haven't found cases that can't be handled yet.

https://github.com/ityonemo/clr


Replies

Panzerschrekyesterday at 7:32 PM

> Exactly the way you suggest, as an optional add-in

No, I don't suggest it, but criticize it. Rust performs its checking as a separate step after actual compilation, which sometimes leads to strange behavior (like borrow errors are shown only after actual compilation errors). I prefer an approach which is integrated with other language mechanisms.

> It's still WIP but in my side project I haven't found cases that can't be handled yet.

It's generally a good idea to write such an analyzer, but I doubt it can be useful without proper integration with the language itself (with huge semantics changes). If it's too strict, it will reject perfectly fine code, but otherwise it will catch only the most obvious errors and approve code having more complex memory bugs.

show 1 reply