3 ms·
> This is really where we are? "Lexical scoping makes programming impossible"? No. "Pass exactly the values" is a subset of lexical scoping, which is much mor
by jlokier 6y ago
> This is really where we are? "Lexical scoping makes programming impossible"?
No.
"Pass exactly the values" is a subset of lexical scoping, which is much more brittle than lexical scoping in general.
> - Pass a configuration object. This means passing at most an argument per layer, rather than an argument per field. Type-safe, faster than a context, overall usually less boilerplate than recasting a context value.
So, a God-object then, what I called "request object". That's regarded by some as an anti-pattern, even though it's type safe.
> overall usually less boilerplate than recasting a context value.
When comparing with context, I agree.
But when comparing with goroutine local storage, which the comment was about, a configuration object passed everywhere is more boilerplate not less.
> bound methods.
I'm not clear on what you have in mind by bound methods, unless the values are lexicals who values must remain the same across all concurrent goroutines.
If that's so, "my sql.DB" probably uses thread-local storage when it needs a usable DB handle anyway, and both that and "my net.Listener" are effectively global variables, potentially breaking modular re-use within a single process.