On Borrow Checking
Timon Gehr
timon.gehr at gmx.ch
Mon May 12 12:52:29 UTC 2025
On 5/11/25 20:03, Walter Bright wrote:
> On 5/11/2025 4:32 AM, Timon Gehr wrote:
>> Well, it's common enough to need type system support.
>
> That's not necessarily true.
You had claimed it is not a severe limitation. It's common enough to
need type system support to not be severely limited.
> You can do everything in C that D does, it's just less convenient.
> ...
Severely so.
>
>> Support for multiple indirections is also important. Rust actually
>> provides both of these.
>
> There are other ways to do that. Multiple indirections can be handled by
> using structs and then only allowing access to structs through member
> function interfaces.
> ...
Well, safe dynamic arrays can be handled by creating a custom struct and
accessing it with API functions that perform bounds checks. Yet C
programmers rarely do this.
>
>>> It's a minor inconvenience that can be refactored away.
>> In general you'll have to resort to `@system` code,
>
> While you can always do it with @system code, I'm not convinced some
> refactoring won't work. It's not a disaster to use @system code now and
> then.
> ...
The best you can usually do is to manually move safety checks to
runtime. The point of a type system in this case is to avoid that
overhead and to give assurances before the program actually runs or even
ships to users.
>
>> and it will stand in the way of other refactorings you may want to do.
>
> You've got to do a lot of refactoring to make Rust code work anyway.
> ...
The inflexibility of Rust is indeed one of the main points of critique
that is directed against it.
More information about the Digitalmars-d
mailing list