`use` statements at top of file or interspersed?

111 points crisbennett

I've seen a few codebases where use statements are placed near their place of usage - ie. above or within functions, as opposed to the more typical (I think?) top of the file.

Does anyone here do this? I quite like it for readability, but it is a bit of overhead to manage. Probably more than it's worth. Unless you're happy with duplicates, you need to manually check whether any have to be lifted up to a common scope.

I think the simplicity and predictability of putting them all at the top of the file is likely best overall. If you do it the other way I'd be interested in whether you see any advantages beyond a small increment in readability.