|
|
|
|
|
by qihqi
18 days ago
|
|
Colored functions are good. It reflects the language design on signaling what is important, and what are the properties it want the writer to pay attention.
Other examples of colored functions: * Haskell: pure function and non-pure (IO monads) looks different.
* Rust: unsafe functions (or block) requires special markers. |
|
In Rust, unsafe code can call safe code, and safe code can call unsafe code. Calling unsafe code in safe code requires an explicit unsafe block, but that's fairly normal and not a hack to get around function coloring.
A better example could be Rust async, though unlike JavaScript, you have the option to block the thread on an async function in a sync function.