← Back to context

Comment by bayindirh

4 months ago

If Eclipse's archaic(!) variable renaming feature for C++ can distinguish between related and unrelated variables which have the same name, you can implement this thing in almost any language.

Eclipse CDT has a real-time static analyzer for the code you're working on though. It's not as naive as it looks from a distance.

Consider this simple C code:

    void inc(int* a, int* b) {
      *a += 1; *b += 2;
    }

Are you adding one to an integer and adding two to another integer, or are you adding three to a single integer?

In other words are the two pointers actually pointing to the same variable? There's no way to know. When you select one pointer, should the other also be highlighted?

But in Rust you cannot have two mutable references to a single variable so the above cannot happen.

Variable renaming is a much much simpler task than this. Of course it is archaic and has existed for a long time.

  • > In other words are the two pointers actually pointing to the same variable?

    This statement is incorrect. You can't have pointers to a variable. You can have pointers to a memory address, and most people would be fine with a tool that is correct up to the level of being unable to differentiate that.

    This is a disingenuous redefinition of what the GP is looking for in order to shill Rust.

  • honestly I'd be ok with a being treated as different than b in this colorized use case. sure, maybe it'd be "bug inducing" or be a subconcious push toward human brains to forget they produced two aliases etc but I think what you're proposing with the c colorizing is impractical and yes I get it, "the tools caused the crash that brought down civilization" but c'mon, if you're still using c, folks have already talked you out of safety nets lol