4 ms·
Generally when talking about colored functions, I think of an example like "async function" in javascript, those are definitely different colored. I don't kno
by hoppp 25d ago
Generally when talking about colored functions, I think of an example like "async function" in javascript, those are definitely different colored.
I don't know about what would constitute as colored function in go as I generally don't consider arguments to be function colors.
Maybe methods in go would be different colored functions when they are defined on different struct types.
- jerf 25d agoI don't think there's a way to color functions in Go. That's not terribly special, several languages have no colors in them.
- zbentley 24d agoPedantically, colored functions in Go might be ones that produce their output on a channel rather than returning a value. Then, you need select/for-range/<- to get their result, similar to “await”. Practically, the runtime’s ability to suspend and move goroutines around means that the impact of that (niche/rarely appropriate as a default approach) kind of coloring is much less in Go than in other languages.
- jerf 24d agoThat has no propagation up the stack at all. Whether a child function does or does not use channels has no effect on the parent.
- mitxela 22d agoreturning error is a function color in Go. That you can discard the error is not relevant, since it creates an incorrect program. Failability is a color in all languages that don't handle it like C (everything is a crash) or like Java (everything can throw - it's not a color if everything is the same color).