Skip to content
Prev 378326 / 398502 Next

Function in default parameter value closing over variables defined later in the enclosing function

My objection to this design pattern is that this gives the default implementation of inside an ability that cannot be altered using functions provided by the caller. You might think this is what you want now but it has the potential to render the code unreusable in the future, which renders the whole idea of making inside an argument to outside pointless. It would be better to also make secret an argument to outside instead of a local variable or to give up on supplying the inside function as an argument.
On January 24, 2019 6:39:49 AM PST, Ivan Krylov <krylov.r00t at gmail.com> wrote: