I wish I had a language that lets me prevent certain functions to have certain effects
What am I hoping to achieve? Type systems usually express the input and output types of a function, but not what side effects the function may have. I want to be able to deny certain side effects in some parts of my code, for safety, correctness or documentation purposes. What are some examples of side effects to forbid? Must not panic, since that leaves my program in an undefined state. Must not access the network, to prevent unwanted calls. Must not access filesystem, to prevent reading local data or having slow performance. Must not write to the filesystem, to prevent causing damage to the persistent system state. Must not allocate memory, to prevent memory exhaustion errors for embedded systems. Must not cause interrupts, to prevent triple faults in interrupt handlers. Must not block, to prevent blocking event threads in async context. Must not syscall, to prevent manipulating the system state. Must not loop, to prevent unbounded loops making the system unresponsive. Must not recurse, to prevent stack overflows. Must not cause non-determinism, to make results deterministic and time independent. Must not branch, to ensure constant execution time, or better GPU core utilization. Must not divide, to prevent division by zero errors. Must not perform floating point arithmetic, to ensure financial code does not suffer rounding errors, or that code is portable to low-end CPUs. Must not spawn threads, to enforce single-threading. Must not lock, useful to ensure and communicate that functions are lock-free. Must not use atomics, to ensure that there is no cache contention risk. Must not use SIMD/vector extensions, to ensure the code remains portable or doesn’t force the CPU into an inefficient processor state. What are the benefits of such a system? There are several benefits to this mechanism: ...