4 ms·
I'm not aware of any languages so simple that renaming an identifier and its usages isn't a useful feature.
by drtz 6y ago
I'm not aware of any languages so simple that renaming an identifier and its usages isn't a useful feature.
- jolmg 6y agoHow often do people rename identifiers for that to be a particularly useful feature? If it's not that often, you might be served fine with something like sed -i 's/foo/bar/g' **.rb It's not precise, so it might take some manual work and tweaking with the patterns, but for how often I've had to rename identifiers, it works good enough to handle the bulk work. A bit of forethought when first naming things works wonders, too.
- gerash 6y agoRefactoring is an essential part of software development. sed is not gonna cut it. The same way that inserting a newline character every 80 or so characters cannot be called source code formatting
- jolmg 6y agoRefactoring doesn't consist only of renaming identifiers, and for the portion that it does, regular vim features like `/`, `c`, `n`, and `.` or macros or such are often enough.
- haxney 6y agoThat only works if the identifier name is unique across your files. What if you have a field on class "Zoo" named "containers" and you want to replace it with "animal_containers", but only for the "Zoo" class? There are probably other usages of "containers" in the code, with no easy way for something like sed to distinguish between "zoo_instance.containers" and "car_instance.containers". You need an editor that can understand "this usage of 'containers' refers only to class 'Zoo', so I should find all variables of type 'Zoo' which reference the 'containers' field and change those."
- jolmg 6y ago> That only works if the identifier name is unique across your files hence > It's not precise, so it might take some manual work and tweaking with the patterns and like I said, > for how often I've had to rename identifiers, it works good enough to handle the bulk work. so > You need an editor that can understand No I don't, because renaming across many files is rare enough that I don't need it. Most of the time, I do refactoring before it's gotten out of hand and so regular vim features like I mentioned in another comment are typically enough. In other words, I think such understanding by the editor is too much complexity (and language-constrained, at that) for little reward.