Hacker News new | ask | show | jobs
by schmichael 1243 days ago
Context is a dependency like any other parameter in a function call. I don't think we should start conflating that with coloring which is distinct from normal parameters: function colors are the result of using language-specific keywords (async, await, yield, etc). These keywords are implemented with compile-time and/or runtime-time support. Context on the other hand is just Go code like any other Go code, and used as a convention, and quite a loose one at that. You can opt out of it with "Background()" at any point.

Also I probably see contexts used as much for supervisor/component management as IO. Most of the stdlib IO APIs lack Context support:

- the io and os packages have 0 references to context

- the "net" package has contexts for dns and making connections, but reads and writes don't use contexts

1 comments

Async/await in Rust is mostly just sugar on top of futures, which you can implement manually. There's plenty of old code in Rust that predates async/await that does just that.
Sure and Python's yield is just sugar around the generator protocol, but both bits of plumbing are quite a bit more sophisticated than "just another function parameter." I know I'm being a bit pedantic, but I think "function colors" ought to mean something a bit more than "a commonly used function parameter."
The phenomenon of “coloured functions” is usually derided because of the way it infects the call tree. In this sense context proliferation is the same phenomenon. Otherwise no one would really care about coloured functions.
Fair enough