Function Arguments Are Not Function Colors

Posted by ingve 3 hours ago

Counter23Comment8OpenOriginal

Comments

Comment by skavi 1 hour ago

Under this framework, Rust's async fns would not be colored, since any function in the callstack could be blocking on an executor. if you consider "spawn point" a part of the callstack, many other languages are similar.

This doesn't feel like a useful distinction, but i don't think "function coloring" in general is a useful framework.

Comment by legobmw99 1 hour ago

I think this is a fine distinction to make, though it's worth noting that function arguments _can be_ colors as the author describes if the arguments have to come from a specific place, e.g. in languages where only `main` receives certain arguments relating to system functionality, or a capability framework where only the top-level function receives the capability token.

Comment by hoppp 2 hours 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.

Comment by jerf 1 hour ago

I don't think there's a way to color functions in Go. That's not terribly special, several languages have no colors in them.

Comment by kelseyfrog 1 hour ago

A subset of function arguments are function colors because async/await is isomorphic to requiring and passing a `callback` arg around. It was named 'callback hell` because there wasn't an escape hatch and it affected every function in the callstack.

I'd venture to guess that there's a more abstract way of formalizing this in the sense that monad instances are required to be threaded through the callstack in particular cases(would love to see this spelled out formally) where IO and Cont(?) have this requirement but State like the author points out, does not.

Comment by jerf 1 hour ago

I think this is a case where you want to avoid architecture astronautics and deal with languages as they are presented. Yes, in the end it's all continuation passing, or depending on the cut of your jib, it's all just assembler in the end, but meanwhile, down in the trenches, there are real, practical differences in color that change how you program in those languages, and that's the topic color addresses.

Comment by kibwen 1 hour ago

"Function colors" are just effect systems, which are not a new concept while also being extremely useful and super nifty. I hope someday we can stop wringing our hands in a panic over "colored functions" just because some ancient version of Javascript had a frustrating implementation of one specific effect. It reminds me of how ages ago certain people acquired an instinctual aversion to static typing attributable entirely to ancient versions of Java and its attendant verbosity and relative anemia.

Comment by dnautics 30 minutes ago

No. Function colors (see criterion 4 in the original article) deal with the idea of "how much of a pain in the ass is it to deal with" which is not really a concept that is a PL theory concept.