Clemens:
> What problems does the static inner function idiom create? It's clean, safe, 
> performant,<

Clean: requiring 3-4 extra lines of code and a second name (for the inner 
function) is less clean. Generally it's better to minimize the number of names 
that you need to invent in a program.

Safe: it requires more code than just a single "private", so there's a little 
more chance of bugs: if you take a look at the code I've written in one of the 
last posts you can see I've forgotten to add "static".

Performant: the performance is probably the same if compiled with LDC, but 
there are two functions, one function call to remove/inline, while the 
"private" requires no extra work to the optimizer.

Idiomatic/documentation: adding "private" in that way you state clearly the 
purpose of what you are doing, and this can be understood by documentation 
generator software and IDEs too, while the idiom of a nested static function 
called inside the outer is less explicit. The semantics is about the same, but 
the first version shows the purpose directly.

Bye,
bearophile

Reply via email to