3 ms·
>This should sound very familiar, dependency injection is just a more controlled form of dynamic scoping. This is not really true. First off, this is too much
by catern 7y ago
>This should sound very familiar, dependency injection is just a more controlled form of dynamic scoping.
This is not really true. First off, this is too much focus on "dependency injection", which is just one usage of a more general feature: passing arguments to functions.
Is dynamic scoping the same thing as passing arguments to functions? Well, they are certainly closely related; for example, see the "implicit parameters" paper[0]. But I think it is incorrect to say that converting a function to take more arguments is "emulating dynamic scoping", any more than function arguments in general are "emulating dynamic scoping".
[0] https://www.researchgate.net/publication/2808232_Implicit_Parameters_Dynamic_Scoping_with_Static_Types https://www.researchgate.net/publication/2808232_Implicit_Pa...