Functions do the same thing, but are more reaadable due to explicit naming.
It can be great though as an intermediate step to extracting functions.
It can be great though as an intermediate step to extracting functions.
Functions do have a place too of course; even single-use ones. Especially when you can give them a clear purpose and name.
Most programmers have no problem, for instance, with seeing multiple loops declared like:
for(int i = ...; ...; ...) { ... }
`i` is "repeated", but there's no objection in having multiple declarations since each has a meaning dependent on its local context.I don't use it often, but when I do, I find it convenient.
And if it turns out I'm wrong about that, the braces provide a very nice, guaranteed cutting point in the future that anyone can understand without having to load all the context of the function.
This isn't the sort of thing I want splattered all over a code base, but it is a nice niche tool.