3 ms·
> now you have polluted the scope Actually they haven't. Using glob imports inside small functions can enhance readability without causing confusion. Otherwise
by Lvl999Noob 2y ago
> now you have polluted the scope
Actually they haven't. Using glob imports inside small functions can enhance readability without causing confusion. Otherwise any kind of aliasing and importing would be polluting the scope since they are bringing other items into your module without the full path.
- account42 2y agoPutting using statements inside small functions is the opposite of ehancing readbility.
- consteval 2y agoI disagree, because the scope doesn't escape those functions and it can greatly reduce the amount of :: Usually in an entire codebase or a module there's a lot of competing, similar symbols. But in a function that's not the case, because they do something small. So there's no benefit to being more "explicit", because the function already states what it does. For example you might not want to use std::chrono. But in, say, a series of timing functions you really don't want to be writing std::chrono:monotonic_clock::now(), do you? You can just use a using and then just call now() or whatever.