this post was submitted on 28 Mar 2024
242 points (94.2% liked)
Rust
5938 readers
1 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Types are not necessary at all.
Saying "x is defined somewhere in the entire program" isn't satisfactory to many users. Also, you didn't tell me what type x has. Can I do
x + 5
?It absolutely does. Without static types an IDE/LSP can't reliably find all the references / definition and therefore can't refactor reliably either.
Consider something like this:
Now imagine you want to rename
Foo.bar
or find all references to it. Impossible without the type annotations.Ah, I see. You're talking about object properties. I don't see any issue with finding references to variables, but for properties, yeah.