|
|
|
|
|
by yazaddaruvala
64 days ago
|
|
An extremely verbose effects system can resolve these dependency permissions at compile time. However, balancing ergonomics is a the big challenge. I personally would prefer less ergonomics for more security, but that’s likely not a broadly shared opinion. |
|
syntax not final obviously and idk if it should be called "effect" or "context" so im using both. every function has to declare them but theres no big ergonomics hit when you have union effects and ide autocomplete. might not be easy to implement this in practice but the concept is simple, its basically some extra objects that get automatically passed through kinda like react context.
a function that takes no context and no &mut parameters is pure, if it takes only "shared" context its view (no side effects but depends on shared state). this can be used to let the compiler optimize better or guarantee security, like proc macros have to be pure or build.rs can only log to a provided output. of course you need to forbid unsafe code in the untrusted module to make it safe.