Skip to content
Tech News
← Back to articles

Function Arguments Are Not Function Colors

read original get The Go Programming Language (Donovan & Kernighan) → more articles
Why This Matters

This piece pushes back on the popular claim that any function parameter (like Go's context.Context) is equivalent to the 'function coloring' problem in async programming. The author proposes a sharper criterion: color is about how a change to a deeply nested function propagates through the call graph, not merely about threading a value through calls. It's a useful clarification for language designers and developers arguing about async ergonomics.

Key Takeaways
Worth a Look

The Go Programming Language (Donovan & Kernighan) — The article digs into Go's context.Context and how arguments thread through call graphs — exactly the kind of design detail this book explains from the ground up. Donovan and Kernighan's classic is a great desk reference for reasoning about Go's concurrency and API conventions.

See The Go Programming Language (Donovan & Kernighan) on Amazon → Affiliate link — we may earn a commission on purchases, at no extra cost to you. Product picked by AI based on this article; it is not a tested recommendation.

In several debates online about function colors over the years, people have argued the apparently reasonable position that function arguments can constitute colors as well.

For instance, in Go, there is a context.Context value, which manages timeouts, cancellation, and a small amount of data that can be threaded through various functions. It is, by design, intended to be something passed through functions even if the receiver doesn’t use it directly but only passes it along. Generally, once one function starts using a context, you should thread it along to all called functions that could conceivably have a use for it.

So, superficially, this appears to be a color. Once you have this particular argument in hand, you “have” to call all future functions of that type with that argument.

Extending this out you can end up arguing that all function parameters are “colors”, as some do.

A quick, though still important, objection is to observe that if this was the case, we wouldn’t be talking about this at all. If async was merely one “color” in a dazzling chaotic rainbow of thousands of other colors, this “color” concept wouldn’t have been invented 50+ years after the invention of programming language functions. There is still something distinct about how async works in some languages that is worth trying to capture and understand.

But understanding the situation deeply from one example is difficult. Here is my attempt to turn it into a criterion rather than a single example:

Color As A Change Dependency Graph Shape

Let’s phrase the problem this way:

Suppose I have to change an attribute of some function 4 levels buried in a call stack, be that a parameter that it takes, whether it is “async” or not, or some other thing like “whether or not it has ASM in it” or any other attribute of the function. Any change to the function at all, depending on what characteristics the local language permits functions to have.

This change could result in having to change the callers as well.

... continue reading