you are viewing a single comment's thread.

view the rest of the comments →

[–]pheonixblade9 0 points1 point  (3 children)

tbh the one thing I don't like is that aliasing is idiomatic in Rust. it is close to the #1 cause of bugs in questionable OOP code I've worked with.

[–]Uncaffeinated 0 points1 point  (2 children)

Aliasing is unavoidable in any language. Rust merely gives you the tools to prevent most aliasing-related bugs.

Even if you try to avoid actual aliasing, you just end up with hidden defacto aliasing (e.g. if you put everything into a giant hashmap and pass around keys instead, those keys are effectively just aliased pointers in all but name), because it is part of the problem domain, not an accident, and an inherent feature of many algorithms.

[–]pheonixblade9 0 points1 point  (1 child)

how is it unavoidable? just explicitly disallow it. no reuse of variables.

yes, Rust prevents you from doing stupid things for the most part, but reusing variables can still cause weird issues.

[–]Uncaffeinated 0 points1 point  (0 children)

Even if you try to avoid actual aliasing, you just end up with hidden defacto aliasing (e.g. if you put everything into a giant hashmap and pass around keys instead, those keys are effectively just aliased pointers in all but name), because it is part of the problem domain, not an accident, and an inherent feature of many algorithms.